1 // applicationwindow.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/17/2010 Added this text. :-)
15 // JLH 05/27/2010 Finished refactoring old Qt3 based action handling code to
16 // Qt4's much more sensible action handling
19 #include "applicationwindow.h"
22 #include "actiondrawlinefree.h"
23 #include "actionlibraryinsert.h"
24 #include "actionprintpreview.h"
26 #include "dialogfactory.h"
27 #include "dimaligned.h"
28 #include "dimlinear.h"
29 #include "dimradial.h"
35 #include "paintinterface.h"
37 #include "scriptlist.h"
40 #include "staticgraphicview.h"
46 #include "camdialog.h"
47 #include "simulationcontrols.h"
51 #include "filedialog.h"
52 #include "pentoolbar.h"
53 #include "recentfiles.h"
54 #include "cadtoolbar.h"
55 #include "cadtoolbarmain.h"
56 #include "coordinatewidget.h"
57 #include "dlgimageoptions.h"
58 #include "mousewidget.h"
59 #include "selectionwidget.h"
61 #include "createqtactions.h"
62 #include "qc_dialogfactory.h"
63 #include "qg_graphicview.h"
65 #include "mdiwindow.h"
67 ApplicationWindow * ApplicationWindow::appWindow = NULL;
70 # define QC_APP_ICON "qcad.png"
73 # define QC_APP_ICON16 "qcad16.png"
76 extern QSplashScreen * splash;
79 * Constructor. Initializes the app.
81 ApplicationWindow::ApplicationWindow():
82 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
83 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
85 DEBUG->print("ApplicationWindow::ApplicationWindow");
88 //no assistant = NULL;
91 DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
92 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
93 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
94 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
95 CreateQtActions(this);
97 DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
98 actionHandler = new ActionHandler(this);
99 DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
102 DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter");
103 scripter = new QS_Scripter(this, this);
104 DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter: OK");
107 DEBUG->print("ApplicationWindow::ApplicationWindow: init view");
109 DEBUG->print("ApplicationWindow::ApplicationWindow: init toolbar");
111 DEBUG->print("ApplicationWindow::ApplicationWindow: init actions");
113 DEBUG->print("ApplicationWindow::ApplicationWindow: init menu bar");
115 DEBUG->print("ApplicationWindow::ApplicationWindow: init status bar");
118 DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory");
119 dialogFactory = new QC_DialogFactory(this, optionWidget);
120 DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK");
121 DEBUG->print("setting dialog factory object");
123 if (DialogFactory::instance() == NULL)
124 DEBUG->print("no DialogFactory instance");
126 DEBUG->print("got DialogFactory instance");
128 DialogFactory::instance()->setFactoryObject(dialogFactory);
129 DEBUG->print("setting dialog factory object: OK");
131 DEBUG->print("ApplicationWindow::ApplicationWindow: init settings");
134 DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI");
137 // Disable menu and toolbar items
138 emit windowsChanged(FALSE);
140 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
141 statusBar()->showMessage("Architektonas Ready", 2000);
142 //setFocusPolicy(WheelFocus);
148 ApplicationWindow::~ApplicationWindow()
150 DEBUG->print("ApplicationWindow::~ApplicationWindow");
152 DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter");
154 DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter: OK");
157 DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler");
158 delete actionHandler;
159 DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler: OK");
161 DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory");
162 delete dialogFactory;
163 DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK");
165 //no DEBUG->print("ApplicationWindow::~ApplicationWindow: "
166 // "deleting assistant..");
167 // if (assistant!=NULL) {
170 // DEBUG->print("ApplicationWindow::~ApplicationWindow: "
171 // "deleting assistant: OK");
172 DEBUG->print("ApplicationWindow::~ApplicationWindow: OK");
176 * Runs the start script if scripting is available.
178 void ApplicationWindow::slotRunStartScript()
180 slotRunScript("autostart.qs");
184 * Runs a script. The action that triggers this slot has to carry the
185 * name of the script file.
187 void ApplicationWindow::slotRunScript()
189 DEBUG->print("ApplicationWindow::slotRunScript");
191 const QObject * s = sender();
195 QString script = ((QAction *)s)->text();
196 DEBUG->print("ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
197 slotRunScript(script);
202 * Runs the script with the given name.
204 void ApplicationWindow::slotRunScript(const QString & name)
207 DEBUG->print("ApplicationWindow::slotRunScript");
209 if (scripter == NULL)
211 DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotRunScript: scripter not initialized");
215 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
217 QStringList scriptList = SYSTEM->getScriptList();
218 scriptList.append(SYSTEM->getHomeDir() + "/.architektonas/" + name);
220 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
222 DEBUG->print("ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
225 if (fi.exists() && fi.fileName() == name)
227 DEBUG->print("ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
228 scripter->runScript(*it, "main");
235 * Called from toolbar buttons that were added by scripts to
238 void ApplicationWindow::slotInsertBlock()
240 const QObject * s = sender();
244 QString block = ((QAction *)s)->text();
245 DEBUG->print("ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
246 slotInsertBlock(block);
251 * Called to insert blocks.
253 void ApplicationWindow::slotInsertBlock(const QString & name)
255 DEBUG->print("ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
257 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
259 GraphicView * graphicView = getGraphicView();
260 Document * document = getDocument();
262 if (graphicView && document)
264 ActionLibraryInsert * action = new ActionLibraryInsert(*document, *graphicView);
265 action->setFile(name);
266 graphicView->setCurrentAction(action);
271 * Shows the main application window and a splash screen.
273 void ApplicationWindow::show()
275 #ifdef QSPLASHSCREEN_H
282 #ifdef QSPLASHSCREEN_H
286 qApp->processEvents();
287 splash->clearMessage();
288 # ifdef QC_DELAYED_SPLASH_SCREEN
289 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
291 finishSplashScreen();
298 * Called when the splash screen has to terminate.
300 void ApplicationWindow::finishSplashScreen()
302 #ifdef QSPLASHSCREEN_H
305 splash->finish(this);
313 * Close Event. Called when the user tries to close the app.
315 void ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
317 DEBUG->print("ApplicationWindow::closeEvent()");
319 DEBUG->print("ApplicationWindow::closeEvent(): OK");
323 * Handles right-clicks for moving back to the last cad tool bar.
325 void ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
327 if (e->button() == Qt::RightButton && cadToolBar != NULL)
328 cadToolBar->showToolBarMain();
334 * Initializes the MDI workspace.
336 void ApplicationWindow::initMDI()
338 DEBUG->print("ApplicationWindow::initMDI() begin");
340 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
341 // Q3VBox * vb = new Q3VBox(this);
342 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
343 // workspace = new QMdiArea(vb);
344 workspace = new QMdiArea(this);
345 // workspace->setScrollBarsEnabled(true);
346 // setCentralWidget(vb);
347 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
348 DEBUG->print("ApplicationWindow::initMDI(): workspace=%08X", workspace);
350 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
351 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
352 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
353 SLOT(slotWindowActivated(QMdiSubWindow *)));
355 DEBUG->print("ApplicationWindow::initMDI() end");
359 * Initializes all QActions of the application.
360 * (Actually, it creates all application menus & toolbars. All actions are
361 * created in CreateQtActions() and simply referenced here.)
363 void ApplicationWindow::initActions()
365 DEBUG->print("ApplicationWindow::initActions()");
370 QMenu * menu = new QMenu(tr("&File"), this);
371 QToolBar * tb = fileToolBar;
372 tb->setWindowTitle("File");
373 // tb->setCloseMode(Q3DockWindow::Undocked);
375 menu->addAction(actionFileNew);
376 tb->addAction(actionFileNew);
377 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
378 menu->addAction(actionFileOpen);
379 tb->addAction(actionFileOpen);
380 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
381 menu->addAction(actionFileSave);
382 tb->addAction(actionFileSave);
383 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
384 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
385 menu->addAction(actionFileSaveAs);
386 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
387 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
388 menu->addAction(actionFileExport);
389 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
390 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
392 menu->addSeparator();
394 menu->addAction(actionFileClose);
395 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
396 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
398 menu->addSeparator();
400 menu->addAction(actionFilePrint);
401 tb->addAction(actionFilePrint);
402 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
403 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
404 menu->addAction(actionFilePrintPreview);
405 tb->addAction(actionFilePrintPreview);
406 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
407 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
408 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
410 menu->addSeparator();
412 menu->addAction(actionFileQuit);
413 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
415 menu->addSeparator();
417 menuBar()->addMenu(menu);
418 addToolBar(Qt::TopToolBarArea, tb);
424 menu = new QMenu(tr("&Edit"), this);
426 tb->setWindowTitle("Edit");
427 // tb->setCloseMode(Q3DockWindow::Undocked);
429 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
430 menu->addAction(actionEditUndo);
431 tb->addAction(actionEditUndo);
432 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
433 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
434 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
435 menu->addAction(actionEditRedo);
436 tb->addAction(actionEditRedo);
437 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
438 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
441 menu->addSeparator();
443 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
444 menu->addAction(actionEditCut);
445 tb->addAction(actionEditCut);
446 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
447 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
448 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
449 menu->addAction(actionEditCopy);
450 tb->addAction(actionEditCopy);
451 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
452 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
453 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
454 menu->addAction(actionEditPaste);
455 tb->addAction(actionEditPaste);
456 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
457 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
459 menu->addSeparator();
461 menu->addAction(actionOptionsGeneral);
462 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
463 menu->addAction(actionOptionsDrawing);
464 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
465 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
467 menuBar()->addMenu(menu);
468 addToolBar(Qt::TopToolBarArea, tb);
472 //menu = new QPopupMenu(this);
473 //menuBar()->insertItem(tr("&Options"), menu);
475 // Viewing / Zooming actions:
477 // menu = new Q3PopupMenu(this);
478 menu = new QMenu(tr("&View"), this);
479 //obsolete: menu->setCheckable(true);
481 tb->setWindowTitle("View");
482 // tb->setCloseMode(Q3DockWindow::Undocked);
484 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
485 menu->addAction(actionViewGrid);
486 tb->addAction(actionViewGrid);
487 actionViewGrid->setChecked(true);
488 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
489 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
490 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
492 settings.beginGroup("Appearance");
493 bool draftMode = settings.value("DraftMode", false).toBool();
496 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
497 menu->addAction(actionViewDraft);
498 tb->addAction(actionViewDraft);
499 actionViewDraft->setChecked(draftMode);
500 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
501 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
502 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
505 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
507 action->setChecked(true);
508 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
510 action->setChecked(true);
511 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
513 action->setChecked(true);
514 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
516 action->setChecked(true);*/
518 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
519 menu->addAction(actionZoomRedraw);
520 tb->addAction(actionZoomRedraw);
521 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
522 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
523 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
524 menu->addAction(actionZoomIn);
525 tb->addAction(actionZoomIn);
526 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
527 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
528 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
529 menu->addAction(actionZoomOut);
530 tb->addAction(actionZoomOut);
531 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
532 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
533 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
534 menu->addAction(actionZoomAuto);
535 tb->addAction(actionZoomAuto);
536 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
537 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
538 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
539 menu->addAction(actionZoomPrevious);
540 tb->addAction(actionZoomPrevious);
541 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
542 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
543 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
544 menu->addAction(actionZoomWindow);
545 tb->addAction(actionZoomWindow);
546 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
547 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
548 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
549 menu->addAction(actionZoomPan);
550 tb->addAction(actionZoomPan);
551 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
552 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
554 menu->addSeparator();
556 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
557 menu->addAction(actionViewStatusbar);
558 actionViewStatusbar->setChecked(true);
559 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
562 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
563 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
565 //Actually, this isn't really needed... This crap is maintained by Qt...
566 //#warning "!!! More stuff to port to Qt4 !!!"
569 menu->addAction(actionFocusCommandLine);
570 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
571 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
572 menuBar()->addMenu(menu);
573 //addToolBar(tb, tr("View"));
574 // addDockWindow(tb, tr("View"), Qt::DockTop);
575 addToolBar(Qt::TopToolBarArea, tb);
577 // Selecting actions:
579 menu = new QMenu(tr("&Select"), this);
580 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
581 menu->addAction(actionDeselectAll);
582 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
583 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
584 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
585 menu->addAction(actionSelectAll);
586 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
587 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
588 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
589 menu->addAction(actionSelectSingle);
590 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
591 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
592 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
593 menu->addAction(actionSelectContour);
594 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
595 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
596 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
597 menu->addAction(actionDeselectWindow);
598 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
599 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
600 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
601 menu->addAction(actionSelectWindow);
602 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
603 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
604 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
605 menu->addAction(actionSelectInvert);
606 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
607 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
608 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
609 menu->addAction(actionSelectIntersected);
610 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
611 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
612 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
613 menu->addAction(actionDeselectIntersected);
614 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
615 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
616 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
617 menu->addAction(actionSelectLayer);
618 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
619 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
620 menuBar()->addMenu(menu);
624 menu = new QMenu(tr("&Draw"), this);
627 QMenu * subMenu = new QMenu(tr("&Point"), this);
628 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
629 subMenu->addAction(actionDrawPoint);
630 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
631 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
632 menu->addMenu(subMenu);
635 subMenu = new QMenu(tr("&Line"), this);
636 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
637 subMenu->addAction(actionDrawLine);
638 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
639 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
640 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
641 subMenu->addAction(actionDrawLineAngle);
642 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
643 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
644 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
645 subMenu->addAction(actionDrawLineHorizontal);
646 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
647 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
648 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
649 subMenu->addAction(actionDrawLineVertical);
650 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
651 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
652 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
653 subMenu->addAction(actionDrawLineRectangle);
654 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
655 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
656 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
657 subMenu->addAction(actionDrawLineParallel);
658 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
659 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
660 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
661 subMenu->addAction(actionDrawLineParallelThrough);
662 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
663 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
664 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
665 subMenu->addAction(actionDrawLineBisector);
666 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
667 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
668 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
669 subMenu->addAction(actionDrawLineTangent1);
670 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
671 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
672 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
673 subMenu->addAction(actionDrawLineTangent2);
674 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
675 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
676 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
677 subMenu->addAction(actionDrawLineOrthogonal);
678 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
679 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
680 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
681 subMenu->addAction(actionDrawLineRelAngle);
682 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
683 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
684 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
685 subMenu->addAction(actionDrawLinePolygon);
686 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
687 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
688 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
689 subMenu->addAction(actionDrawLinePolygon2);
690 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
691 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
692 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
693 subMenu->addAction(actionDrawLineFree);
694 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
695 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
696 menu->addMenu(subMenu);
699 subMenu = new QMenu(tr("&Arc"), this);
700 subMenu->addAction(actionDrawArc);
701 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
702 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
703 subMenu->addAction(actionDrawArc3P);
704 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
705 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
706 subMenu->addAction(actionDrawArcParallel);
707 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
708 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
709 subMenu->addAction(actionDrawArcTangential);
710 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
711 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
712 menu->addMenu(subMenu);
715 subMenu = new QMenu(tr("&Circle"), this);
716 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
717 subMenu->addAction(actionDrawCircle);
718 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
719 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
720 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
721 subMenu->addAction(actionDrawCircleCR);
722 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
723 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
724 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
725 subMenu->addAction(actionDrawCircle2P);
726 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
727 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
728 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
729 subMenu->addAction(actionDrawCircle3P);
730 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
731 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
732 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
733 subMenu->addAction(actionDrawCircleParallel);
734 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
735 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
736 menu->addMenu(subMenu);
739 subMenu = new QMenu(tr("&Ellipse"), this);
740 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
741 subMenu->addAction(actionDrawEllipseAxis);
742 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
743 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
744 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
745 subMenu->addAction(actionDrawEllipseArcAxis);
746 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
747 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
748 menu->addMenu(subMenu);
751 subMenu = new QMenu(tr("&Spline"), this);
752 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
753 subMenu->addAction(actionDrawSpline);
754 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
755 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
756 menu->addMenu(subMenu);
759 subMenu = new QMenu(tr("&Polyline"), this);
760 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
761 subMenu->addAction(actionDrawPolyline);
762 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
763 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
764 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
765 subMenu->addAction(actionPolylineAdd);
766 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
767 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
768 subMenu->addAction(actionPolylineAppend);
769 connect(actionPolylineAppend, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAppend()));
770 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAppend, SLOT(setEnabled(bool)));
771 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
772 subMenu->addAction(actionPolylineDel);
773 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
774 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
775 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
776 subMenu->addAction(actionPolylineDelBetween);
777 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
778 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
779 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
780 subMenu->addAction(actionPolylineTrim);
781 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
782 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
783 menu->addMenu(subMenu);
786 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
787 menu->addAction(actionDrawText);
788 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
789 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
791 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
792 menu->addAction(actionDrawHatch);
793 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
794 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
796 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
797 menu->addAction(actionDrawImage);
798 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
799 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
800 // menuBar()->insertItem(tr("&Draw"), menu);
801 menuBar()->addMenu(menu);
803 // Dimensioning actions:
809 menu = new QMenu(tr("&Dimension"), this);
810 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
811 menu->addAction(actionDimAligned);
812 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
813 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
814 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
815 menu->addAction(actionDimLinear);
816 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
817 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
818 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
819 menu->addAction(actionDimLinearHor);
820 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
821 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
822 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
823 menu->addAction(actionDimLinearVer);
824 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
825 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
826 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
827 menu->addAction(actionDimRadial);
828 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
829 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
830 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
831 menu->addAction(actionDimDiametric);
832 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
833 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
834 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
835 menu->addAction(actionDimAngular);
836 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
837 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
838 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
839 menu->addAction(actionDimLeader);
840 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
841 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
843 m->insertItem(tr("&Dimension"), menu);
845 menuBar()->addMenu(menu);
848 // Modifying actions:
850 menu = new QMenu(tr("&Modify"), this);
851 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
852 menu->addAction(actionModifyMove);
853 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
854 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
855 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
856 menu->addAction(actionModifyRotate);
857 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
858 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
859 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
860 menu->addAction(actionModifyScale);
861 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
862 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
863 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
864 menu->addAction(actionModifyMirror);
865 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
866 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
867 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
868 menu->addAction(actionModifyMoveRotate);
869 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
870 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
871 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
872 menu->addAction(actionModifyRotate2);
873 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
874 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
875 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
876 menu->addAction(actionModifyTrim);
877 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
878 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
879 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
880 menu->addAction(actionModifyTrim2);
881 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
882 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
883 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
884 menu->addAction(actionModifyTrimAmount);
885 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
886 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
887 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
888 menu->addAction(actionModifyBevel);
889 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
890 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
891 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
892 menu->addAction(actionModifyRound);
893 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
894 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
895 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
896 menu->addAction(actionModifyCut);
897 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
898 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
899 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
900 menu->addAction(actionModifyStretch);
901 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
902 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
903 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
904 menu->addAction(actionModifyEntity);
905 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
906 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
907 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
908 menu->addAction(actionModifyAttributes);
909 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
910 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
911 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
912 menu->addAction(actionModifyDelete);
913 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
914 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
915 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
916 menu->addAction(actionModifyDeleteQuick);
917 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
918 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
919 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
920 menu->addAction(actionModifyExplodeText);
921 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
922 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
923 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
924 //// menu->addAction(action);
925 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
926 menu->addAction(actionBlocksExplode);
927 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
928 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
929 menuBar()->addMenu(menu);
933 menu = new QMenu(tr("&Snap"), this);
934 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
935 menu->addAction(actionSnapFree);
936 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
937 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
938 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
939 actionSnapFree->setChecked(true);
940 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
941 menu->addAction(actionSnapGrid);
942 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
943 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
944 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
945 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
946 menu->addAction(actionSnapEndpoint);
947 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
948 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
949 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
950 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
951 menu->addAction(actionSnapOnEntity);
952 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
953 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
954 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
955 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
956 menu->addAction(actionSnapCenter);
957 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
958 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
959 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
960 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
961 menu->addAction(actionSnapMiddle);
962 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
963 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
964 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
965 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
966 menu->addAction(actionSnapDist);
967 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
968 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
969 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
970 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
971 menu->addAction(actionSnapIntersection);
972 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
973 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
974 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
975 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
976 menu->addAction(actionSnapIntersectionManual);
977 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
978 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
979 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
981 menu->addSeparator();
983 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
984 menu->addAction(actionRestrictNothing);
985 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
986 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
987 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
988 actionRestrictNothing->setChecked(true);
989 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
990 menu->addAction(actionRestrictOrthogonal);
991 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
992 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
993 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
994 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
995 menu->addAction(actionRestrictHorizontal);
996 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
997 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
998 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
999 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
1000 menu->addAction(actionRestrictVertical);
1001 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
1002 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
1003 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
1005 menu->addSeparator();
1007 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1008 menu->addAction(actionSetRelativeZero);
1009 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1010 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1011 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1012 menu->addAction(actionLockRelativeZero);
1013 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1014 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1015 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1016 menuBar()->addMenu(menu);
1021 menu = new QMenu(tr("&Info"), this);
1022 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1023 //menu->addAction(action);
1024 menu->addAction(actionInfoDist);
1025 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1026 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1027 menu->addAction(actionInfoDist2);
1028 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1029 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1030 menu->addAction(actionInfoAngle);
1031 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1032 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1033 menu->addAction(actionInfoTotalLength);
1034 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1035 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1036 menu->addAction(actionInfoArea);
1037 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1038 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1039 menuBar()->addMenu(menu);
1044 menu = new QMenu(tr("&Layer"), this);
1045 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1046 menu->addAction(actionLayersDefreezeAll);
1047 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1048 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1049 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1050 menu->addAction(actionLayersFreezeAll);
1051 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1052 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1053 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1054 menu->addAction(actionLayersAdd);
1055 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1056 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1057 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1058 menu->addAction(actionLayersRemove);
1059 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1060 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1061 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1062 menu->addAction(actionLayersEdit);
1063 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1064 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1065 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1066 menu->addAction(actionLayersToggleView);
1067 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1068 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1069 menuBar()->addMenu(menu);
1073 menu = new QMenu(tr("&Block"), this);
1074 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1075 menu->addAction(actionBlocksDefreezeAll);
1076 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1077 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1078 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1079 menu->addAction(actionBlocksFreezeAll);
1080 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1081 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1082 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1083 menu->addAction(actionBlocksAdd);
1084 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1085 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1086 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1087 menu->addAction(actionBlocksRemove);
1088 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1089 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1090 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1091 menu->addAction(actionBlocksAttributes);
1092 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1093 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1094 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1095 menu->addAction(actionBlocksInsert);
1096 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1097 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1098 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1099 menu->addAction(actionBlocksEdit);
1100 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1101 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1102 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1103 menu->addAction(actionBlocksCreate);
1104 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1105 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1106 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1107 menu->addAction(actionBlocksExplode);
1108 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1109 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1110 menuBar()->addMenu(menu);
1112 //will *this* make a toolbar break for us???
1113 addToolBarBreak(Qt::TopToolBarArea);
1114 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1115 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1116 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1117 addToolBar(Qt::TopToolBarArea, optionWidget);
1122 scriptMenu = new QMenu(this);
1123 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1124 scriptOpenIDE->addTo(scriptMenu);
1125 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1126 scriptRun->addTo(scriptMenu);
1129 scriptOpenIDE = NULL;
1135 menu = new QMenu(tr("&CAM"), this);
1136 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1137 menu->addAction(action);
1138 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1139 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1140 menu->addAction(action);
1141 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1142 menuBar()->addMenu(menu);
1147 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1148 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1149 helpAboutApp->setStatusTip(tr("About the application"));
1150 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1151 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1153 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1154 helpManual->setShortcut(Qt::Key_F1);
1155 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1156 helpManual->setStatusTip(tr("Launch the online manual"));
1157 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1159 testDumpEntities = new QAction("Dump &Entities", this);
1160 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1161 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1163 testDumpUndo = new QAction("Undo Info", this);
1164 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1165 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1167 testUpdateInserts = new QAction("&Update Inserts", this);
1168 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1169 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1171 testDrawFreehand = new QAction("Draw Freehand", this);
1172 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1173 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1175 testInsertBlock = new QAction("Insert Block", this);
1176 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1177 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1179 testInsertText = new QAction("Insert Text", this);
1180 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1181 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1183 testInsertImage = new QAction("Insert Image", this);
1184 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1185 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1187 testUnicode = new QAction("Unicode", this);
1188 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1189 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1191 testInsertEllipse = new QAction("Insert Ellipse", this);
1192 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1193 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1195 testMath01 = new QAction("Math01", this);
1196 // testMath01 = new QAction("Math01", "Math01", 0, this);
1197 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1199 testResize640 = new QAction("Resize 1", this);
1200 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1201 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1203 testResize800 = new QAction("Resize 2", this);
1204 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1205 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1207 testResize1024 = new QAction("Resize 3", this);
1208 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1209 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1213 * Initializes the menu bar.
1215 void ApplicationWindow::initMenuBar()
1217 DEBUG->print("ApplicationWindow::initMenuBar()");
1219 // menuBar entry windowsMenu
1220 windowsMenu = new QMenu(tr("&Window"), this);
1221 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1222 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1224 // menuBar entry scriptMenu
1225 //scriptMenu = new QPopupMenu(this);
1226 //scriptMenu->setCheckable(true);
1227 //scriptOpenIDE->addTo(scriptMenu);
1228 //scriptRun->addTo(scriptMenu);
1229 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1231 // menuBar entry helpMenu
1232 helpMenu = new QMenu(tr("&Help"), this);
1233 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1235 // helpMenu->insertSeparator(helpManual);
1236 helpMenu->addSeparator();
1238 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1240 // menuBar entry test menu
1241 testMenu = new QMenu(tr("De&bugging"), this);
1242 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1243 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1244 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1245 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1246 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1247 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1248 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1249 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1250 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1251 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1252 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1253 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1254 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1256 // menuBar configuration
1258 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1259 menuBar()->addMenu(scriptMenu);
1261 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1262 menuBar()->addMenu(windowsMenu);
1264 // menuBar()->insertSeparator();
1265 // menuBar()->insertItem(tr("&Help"), helpMenu);
1266 menuBar()->addMenu(helpMenu);
1269 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1270 menuBar()->addMenu(testMenu);
1272 recentFiles = new RecentFiles(this, fileMenu);
1276 * Initializes the tool bars (file tool bar and pen tool bar).
1278 void ApplicationWindow::initToolBar()
1280 DEBUG->print("ApplicationWindow::initToolBar()");
1282 // fileToolBar = new Q3ToolBar(this, "File Operations");
1283 fileToolBar = addToolBar(tr("File Operations"));
1284 fileToolBar->setObjectName("file");
1285 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1286 editToolBar = addToolBar(tr("Edit Operations"));
1287 editToolBar->setObjectName("edit");
1288 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1289 zoomToolBar = addToolBar(tr("Zoom Operations"));
1290 zoomToolBar->setObjectName("zoom");
1291 penToolBar = new PenToolBar(this, "Pen Selection");
1292 penToolBar->setObjectName("pen");
1294 connect(penToolBar, SIGNAL(penChanged(Pen)), this, SLOT(slotPenChanged(Pen)));
1296 // optionWidget = new Q3ToolBar(this, "Tool Options");
1297 //addToolBarBreak() does nothing...
1298 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1299 // addToolBarBreak(Qt::TopToolBarArea);
1300 optionWidget = addToolBar(tr("Tool Options"));
1301 optionWidget->setObjectName("tooloptions");
1302 optionWidget->setMinimumHeight(26);
1303 optionWidget->setMaximumHeight(26);
1304 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1305 //Maybe sizePolicy or somesuch??
1306 optionWidget->setMinimumWidth(150);
1307 optionWidget->setMaximumWidth(800);
1308 #warning "Following line commented out..."
1309 // optionWidget->setFixedExtentHeight(26);
1310 // optionWidget->setHorizontallyStretchable(true);
1311 // addDockWindow(optionWidget, DockTop, true);
1313 // CAD toolbar left:
1314 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1315 QToolBar * t = addToolBar(tr("CAD Tools"));
1316 t->setObjectName("cadtools");
1317 #warning "Following two lines commented out..."
1318 // t->setFixedExtentWidth(59);
1319 t->setMinimumWidth(59);
1320 t->setMaximumWidth(59);
1321 // t->setVerticallyStretchable(true);
1322 // addDockWindow(t, Qt::DockLeft, false);
1323 addToolBar(Qt::LeftToolBarArea, t);
1325 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1326 cadToolBar->createSubToolBars(actionHandler);
1328 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1329 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1331 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1332 //No, no break inserted here either...
1333 // insertToolBarBreak(optionWidget);
1337 * Initializes the status bar at the bottom.
1339 void ApplicationWindow::initStatusBar()
1341 DEBUG->print("ApplicationWindow::initStatusBar()");
1343 statusBar()->setMinimumHeight(32);
1344 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1345 statusBar()->addWidget(coordinateWidget);
1346 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1347 statusBar()->addWidget(mouseWidget);
1348 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1349 statusBar()->addWidget(selectionWidget);
1353 * Initializes the global application settings from the
1354 * config file (unix, mac) or registry (windows).
1356 void ApplicationWindow::initSettings()
1358 DEBUG->print("ApplicationWindow::initSettings()");
1359 settings.beginGroup("RecentFiles");
1361 for(int i=0; i<recentFiles->Maximum(); ++i)
1363 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1365 if (!filename.isEmpty())
1366 // recentFiles->add(filename);
1367 recentFiles->add(filename);
1370 settings.endGroup();
1372 if (recentFiles->count() > 0)
1373 // updateRecentFilesMenu();
1374 recentFiles->UpdateGUI();
1376 settings.beginGroup("Geometry");
1377 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1378 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1379 restoreState(settings.value("DockWindows").toByteArray());
1380 settings.endGroup();
1383 // if (windowY < 30)
1385 if (windowSize.y() < 30)
1386 windowSize.y() = 30;
1394 * Stores the global application settings to file or registry.
1396 void ApplicationWindow::storeSettings()
1398 DEBUG->print("ApplicationWindow::storeSettings()");
1400 settings.beginGroup("RecentFiles");
1402 for(int i=0; i<recentFiles->count(); ++i)
1403 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1405 settings.endGroup();
1407 settings.beginGroup("Geometry");
1408 settings.setValue("WindowSize", size());
1409 settings.setValue("WindowPos", pos());
1410 settings.setValue("DockWindows", saveState());
1411 settings.endGroup();
1413 DEBUG->print("ApplicationWindow::storeSettings(): OK");
1417 * Initializes the view.
1419 void ApplicationWindow::initView()
1421 DEBUG->print("ApplicationWindow::initView()");
1423 DEBUG->print("init view..");
1427 libraryWidget = NULL;
1428 commandWidget = NULL;
1430 simulationControls = NULL;
1434 DEBUG->print(" simulation widget..");
1435 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1436 simulationControls = new RS_SimulationControls(dw, "Simulation");
1437 simulationControls->setFocusPolicy(Qt::NoFocus);
1438 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1439 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1440 dw->setWidget(simulationControls);
1441 dw->resize(240, 80);
1442 dw->setResizeEnabled(true);
1443 dw->setFixedExtentWidth(120);
1444 dw->setFixedHeight(80);
1445 dw->setCaption(tr("Simulation Controls"));
1446 dw->setCloseMode(Q3DockWindow::Always);
1447 addDockWindow(dw, Qt::DockRight);
1448 simulationDockWindow = dw;
1449 //simulationDockWindow->hide();
1452 DEBUG->print(" layer widget..");
1453 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1454 dw = new QDockWidget(tr("Layer List"), this);
1455 dw->setObjectName("layer");
1456 layerWidget = new LayerWidget(actionHandler, dw, "Layer");
1457 layerWidget->setFocusPolicy(Qt::NoFocus);
1458 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1459 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1460 dw->setWidget(layerWidget);
1461 #warning "following four lines commented out..."
1462 // dw->setFixedExtentWidth(120);
1463 // dw->setResizeEnabled(true);
1464 // dw->setCloseMode(Q3DockWindow::Always);
1465 // dw->setCaption(tr("Layer List"));
1466 addDockWidget(Qt::RightDockWidgetArea, dw);
1467 layerDockWindow = dw;
1469 DEBUG->print(" block widget..");
1470 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1471 dw = new QDockWidget(tr("Block List"), this);
1472 dw->setObjectName("block");
1473 blockWidget = new BlockWidget(actionHandler, dw, "Block");
1474 blockWidget->setFocusPolicy(Qt::NoFocus);
1475 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1476 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1477 dw->setWidget(blockWidget);
1478 #warning "following four lines commented out..."
1479 // dw->setFixedExtentWidth(120);
1480 // dw->setResizeEnabled(true);
1481 // dw->setCloseMode(Q3DockWindow::Always);
1482 // dw->setCaption(tr("Block List"));
1483 addDockWidget(Qt::RightDockWidgetArea, dw);
1484 blockDockWindow = dw;
1486 DEBUG->print(" library widget..");
1487 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1488 dw = new QDockWidget(tr("Library Browser"), this);
1489 dw->setObjectName("library");
1490 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1491 libraryWidget->setActionHandler(actionHandler);
1492 libraryWidget->setFocusPolicy(Qt::NoFocus);
1493 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1495 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1496 dw->setWidget(libraryWidget);
1497 dw->resize(240, 400);
1498 #warning "following three lines commented out..."
1499 // dw->setResizeEnabled(true);
1500 // dw->setCloseMode(Q3DockWindow::Always);
1501 // dw->setCaption(tr("Library Browser"));
1502 //not sure how to fix this one
1503 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1504 // addDockWidget(Qt::NoDockWidgetArea, dw);
1505 //This works, but sux
1506 addDockWidget(Qt::RightDockWidgetArea, dw);
1507 libraryDockWindow = dw;
1508 // libraryDockWindow->hide();
1510 DEBUG->print(" command widget..");
1511 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1512 dw = new QDockWidget(tr("Command line"), this);
1513 dw->setObjectName("command");
1514 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1515 commandWidget->setActionHandler(actionHandler);
1516 // commandWidget->redirectStderr();
1517 // std::cerr << "Ready.\n";
1518 // commandWidget->processStderr();
1519 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1520 dw->setWidget(commandWidget);
1521 #warning "following four lines commented out..."
1522 // dw->setFixedExtentHeight(45);
1523 // dw->setResizeEnabled(true);
1524 // dw->setCloseMode(QDockWidget::Always);
1525 // dw->setCaption(tr("Command line"));
1526 commandDockWindow = dw;
1527 addDockWidget(Qt::BottomDockWidgetArea, dw);
1529 DEBUG->print(" done");
1533 * Creates a new toolbar.
1534 * Implementation from QG_MainWindowInterface.
1535 * Can be called from scripts to add individual GUI elements.
1537 /*QToolBar* ApplicationWindow::createToolBar(const QString& name) {
1538 QToolBar* tb = new QToolBar(this, name);
1544 * Creates a new button in the given tool bar for running a script.
1546 /*void ApplicationWindow::addToolBarButton(QToolBar* tb) {
1548 QAction* action = new QAction("Blah",
1549 QPixmap::fromMimeSource("zoomwindow.png"),
1550 "&Blah", QKeySequence(), NULL);
1551 action->setStatusTip("Blah blah");
1557 * Goes back to the previous menu or one step in the current action.
1559 void ApplicationWindow::slotBack()
1561 GraphicView * graphicView = getGraphicView();
1564 graphicView->back();
1568 cadToolBar->showToolBar(RS2::ToolBarMain);
1573 * Goes one step further in the current action.
1575 void ApplicationWindow::slotEnter()
1577 if (!commandWidget || !commandWidget->checkFocus())
1580 cadToolBar->forceNext();
1583 GraphicView * graphicView = getGraphicView();
1586 graphicView->enter();
1592 * Sets the keyboard focus on the command line.
1594 void ApplicationWindow::slotFocusCommandLine()
1596 if (commandWidget->isVisible())
1597 commandWidget->setFocus();
1601 * Shows the given error on the command line.
1603 void ApplicationWindow::slotError(const QString & msg)
1605 commandWidget->appendHistory(msg);
1609 * Hands focus back to the application window. In the rare event
1610 * of a escape press from the layer widget (e.g after switching desktops
1613 void ApplicationWindow::slotFocus()
1615 //QG_GraphicView* graphicView = getGraphicView();
1616 /*if (graphicView!=NULL) {
1617 graphicView->setFocus();
1625 * Called when a document window was activated.
1627 void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1629 DEBUG->print("ApplicationWindow::slotWindowActivated begin");
1631 //the following does: return (MDIWindow *)workspace->activeSubWindow();
1632 //which means the subwindow is NOT being activated!!!
1633 MDIWindow * m = getMDIWindow();
1634 DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
1637 DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1639 if (m && m->getDocument())
1641 //m->setWindowState(WindowMaximized);
1643 DEBUG->print("ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1645 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1646 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1647 coordinateWidget->setGraphic(m->getGraphic());
1650 simulationControls->setGraphicView(m->getGraphicView());
1653 // Only graphics show blocks. (blocks don't)
1654 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1655 blockWidget->setBlockList(m->getDocument()->getBlockList());
1657 blockWidget->setBlockList(NULL);
1659 // Update all inserts in this graphic (blocks might have changed):
1660 m->getDocument()->updateInserts();
1661 m->getGraphicView()->redraw();
1663 // set snapmode from snapping menu
1664 actionHandler->updateSnapMode();
1666 // set pen from pen toolbar
1667 slotPenChanged(penToolBar->getPen());
1669 // update toggle button status:
1670 if (m->getGraphic())
1672 emit(gridChanged(m->getGraphic()->isGridOn()));
1673 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1677 //Seems to work now.
1678 //#warning "This is failing... !!! FIX !!!"
1679 // Disable/Enable menu and toolbar items
1680 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1682 DEBUG->print("ApplicationWindow::slotWindowActivated end");
1686 * Called when the menu 'windows' is about to be shown.
1687 * This is used to update the window list in the menu.
1689 void ApplicationWindow::slotWindowsMenuAboutToShow()
1691 DEBUG->print("ApplicationWindow::slotWindowsMenuAboutToShow");
1693 windowsMenu->clear();
1695 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1696 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1697 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1699 if (workspace->subWindowList().isEmpty())
1701 windowsMenu->setItemEnabled(cascadeId, false);
1702 windowsMenu->setItemEnabled(tileId, false);
1703 windowsMenu->setItemEnabled(horTileId, false);
1706 windowsMenu->insertSeparator();
1708 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1710 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1712 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1714 for(int i=0; i<int(windows.count()); ++i)
1716 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1717 //For some reason the triggered() signal created here is type bool... Dunno why...
1718 //It's signalling using the QAction signal, which is type bool (checked or not).
1720 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1721 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1722 QAction * action = new QAction(actionName, this);
1723 action->setCheckable(true);
1725 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1726 windowsMenu->addAction(action);
1727 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1728 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1730 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1731 // SLOT(slotWindowsMenuActivated(int)));
1732 SLOT(slotWindowsMenuActivated(QAction *)));
1734 // windowsMenu->setItemParameter(id, i);
1735 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1737 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1743 * Called when the user selects a document window from the
1746 void ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1748 DEBUG->print("ApplicationWindow::slotWindowsMenuActivated");
1750 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1751 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1759 * Tiles MDI windows horizontally.
1761 void ApplicationWindow::slotTileHorizontal()
1763 DEBUG->print("ApplicationWindow::slotTileHorizontal");
1766 // primitive horizontal tiling
1767 QWidgetList windows = workspace->windowList();
1769 if (windows.count() == 0)
1772 int heightForEach = workspace->height() / windows.count();
1775 for(int i=0; i<int(windows.count()); ++i)
1777 QWidget * window = windows.at(i);
1779 #warning "Need to port to Qt4... !!! FIX !!!"
1781 if (window->testWState(WState_Maximized))
1785 window->showNormal();
1789 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1790 int actHeight = QMAX(heightForEach, preferredHeight);
1792 // window->parentWidget()->resize(workspace->width(), actHeight);
1793 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1797 workspace->tileSubWindows();
1802 * Tiles MDI windows vertically.
1804 void ApplicationWindow::slotTileVertical()
1810 QWidgetList windows = workspace->windowList();
1811 if (windows.count()==0) {
1815 //int heightForEach = workspace->height() / windows.count();
1817 for (int i=0; i<int(windows.count()); ++i) {
1818 QWidget *window = windows.at(i);
1819 if (window->testWState(WState_Maximized)) {
1822 window->showNormal();
1824 //int preferredHeight = window->minimumHeight()
1825 // + window->parentWidget()->baseSize().height();
1826 //int actHeight = QMAX(heightForEach, preferredHeight);
1828 //window->parentWidget()->setGeometry(0, y,
1829 // workspace->width(), actHeight);
1830 //window->parentWidget()->resize(window->parentWidget()->width(),
1831 // window->parentWidget()->height());
1832 //window->resize(window->width(), window->height());
1837 workspace->tileSubWindows();
1846 void ApplicationWindow::slotCamExportAuto() {
1847 printf("CAM export..\n");
1849 Document* d = getDocument();
1851 Drawing* graphic = (Drawing*)d;
1853 RS_CamDialog dlg(graphic, this);
1861 * Called when something changed in the pen tool bar
1862 * (e.g. color, width, style).
1864 void ApplicationWindow::slotPenChanged(Pen pen)
1866 DEBUG->print("ApplicationWindow::slotPenChanged() begin");
1867 DEBUG->print("Setting active pen...");
1868 MDIWindow * m = getMDIWindow();
1871 m->slotPenChanged(pen);
1873 DEBUG->print("ApplicationWindow::slotPenChanged() end");
1877 * Creates a new MDI window with the given document or a new
1878 * document if 'doc' is NULL.
1880 MDIWindow * ApplicationWindow::slotFileNew(Document * doc)
1882 DEBUG->print("ApplicationWindow::slotFileNew() begin");
1887 statusBar()->showMessage(tr("Creating new file..."));
1889 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1890 DEBUG->print(" creating MDI window");
1891 // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1892 MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow);
1893 w->setAttribute(Qt::WA_DeleteOnClose);
1894 // w->setWindowState(WindowMaximized);
1895 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1897 if (w->getDocument()->rtti() == RS2::EntityBlock)
1898 // w->setCaption(tr("Block '%1'").arg(((Block *)(w->getDocument()))->getName()));
1899 w->setWindowTitle(tr("Block '%1'").arg(((Block *)(w->getDocument()))->getName()));
1901 // w->setCaption(tr("unnamed document %1").arg(id));
1902 w->setWindowTitle(tr("unnamed document %1").arg(id));
1904 // w->setIcon(qPixmapFromMimeSource("document.png"));
1905 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1906 w->setWindowIcon(QIcon(":/res/document.png"));
1908 // only graphics offer block lists, blocks don't
1909 DEBUG->print(" adding listeners");
1910 Drawing * graphic = w->getDocument()->getGraphic();
1913 if (graphic != NULL)
1915 // Link the graphic's layer list to the pen tool bar
1916 graphic->addLayerListListener(penToolBar);
1917 // Link the layer list to the layer widget
1918 graphic->addLayerListListener(layerWidget);
1919 // Link the block list to the block widget
1920 graphic->addBlockListListener(blockWidget);
1924 // Link the dialog factory to the mouse widget:
1925 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1926 // Link the dialog factory to the coordinate widget:
1927 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1928 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1929 // Link the dialog factory to the option widget:
1930 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1931 // Link the dialog factory to the cad tool bar:
1932 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1933 // Link the dialog factory to the command widget:
1934 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1935 // Link the dialog factory to the main app window:
1936 QG_DIALOGFACTORY->setMainWindow(this);
1938 #if 1 //bugfix for Qt3->4 conversion
1939 DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1940 // workspace->addWindow(w);
1941 workspace->addSubWindow(w);
1944 DEBUG->print(" showing MDI window");
1947 #warning "w->showMaximized() doesn't seem to do anything here..."
1948 //but then again, the subWindowList isn't going to be empty at this point either...
1949 if (workspace->subWindowList().isEmpty())
1955 #warning "!!! SubWindow is not being activated !!!"
1956 //neither of these is working... Is the event being eaten somewhere???
1957 // workspace->activateNextSubWindow();
1959 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1962 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1963 slotWindowActivated(w);
1964 statusBar()->showMessage(tr("New Drawing created."), 2000);
1966 DEBUG->print("ApplicationWindow::slotFileNew() OK");
1973 * Menu file -> open.
1975 void ApplicationWindow::slotFileOpen()
1977 DEBUG->print("ApplicationWindow::slotFileOpen()");
1979 DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1980 RS2::FormatType type = RS2::FormatUnknown;
1981 DEBUG->print("ApplicationWindow::slotFileOpen() 002");
1982 QString fileName = FileDialog::getOpenFileName(this, &type);
1983 DEBUG->print("ApplicationWindow::slotFileOpen() 003");
1984 slotFileOpen(fileName, type);
1985 DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
1989 * Called when a recently opened file is chosen from the list in the
1992 void ApplicationWindow::slotFileOpenRecent(void)
1995 DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
1997 statusBar()->showMessage(tr("Opening recent file..."));
1998 QString fileName = recentFiles->get(id);
2000 if (fileName.endsWith(" (DXF 1)"))
2001 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2003 slotFileOpen(fileName, RS2::FormatUnknown);
2005 statusBar()->showMessage(tr("Opening recent file..."));
2007 QAction * action = qobject_cast<QAction *>(sender());
2012 QString fileName = action->data().toString();
2014 if (fileName.endsWith(" (DXF 1)"))
2015 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2017 slotFileOpen(fileName, RS2::FormatUnknown);
2022 * Menu file -> open.
2024 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2026 DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2027 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2029 if (!fileName.isEmpty())
2031 DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2032 // Create new document window:
2033 MDIWindow * w = slotFileNew();
2034 DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
2035 // link the layer widget to the new document:
2036 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2037 // link the block widget to the new document:
2038 blockWidget->setBlockList(w->getDocument()->getBlockList());
2039 // link coordinate widget to graphic
2040 coordinateWidget->setGraphic(w->getGraphic());
2042 // link the layer widget to the new document:
2043 simulationControls->setGraphicView(w->getGraphicView());
2045 DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2047 // Open the file in the new view:
2048 if (!w->slotFileOpen(fileName, type))
2051 QApplication::restoreOverrideCursor();
2052 QMessageBox::information(this, QMessageBox::tr("Warning"),
2053 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2054 w->setForceClosing(true);
2059 DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2060 DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2062 // update recent files menu:
2063 if (type == RS2::FormatDXF1)
2064 recentFiles->add(fileName + " (DXF 1)");
2066 recentFiles->add(fileName);
2068 DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2069 recentFiles->UpdateGUI();
2070 DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2071 DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2073 w->setWindowTitle(fileName);
2074 DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2075 DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2076 // update coordinate widget format:
2077 DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2078 DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2079 // Update the layer and block widgets (document just loaded may have some)
2080 layerWidget->update();
2081 blockWidget->update();
2082 // show output of filter (if any):
2083 QString message = tr("Loaded document: ") + fileName;
2084 commandWidget->appendHistory(message);
2085 statusBar()->showMessage(message, 2000);
2089 statusBar()->showMessage(tr("Opening aborted"), 2000);
2092 QApplication::restoreOverrideCursor();
2093 DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2097 * Menu file -> save.
2099 void ApplicationWindow::slotFileSave()
2101 DEBUG->print("ApplicationWindow::slotFileSave()");
2103 statusBar()->showMessage(tr("Saving drawing..."));
2105 MDIWindow * w = getMDIWindow();
2110 if (w->getDocument()->getFilename().isEmpty())
2116 if (w->slotFileSave(cancelled))
2120 name = w->getDocument()->getFilename();
2121 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2127 QMessageBox::information(this, QMessageBox::tr("Warning"),
2128 tr("Cannot save the file\n%1\nPlease check the permissions.")
2129 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2136 * Menu file -> save as.
2138 void ApplicationWindow::slotFileSaveAs()
2140 DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2142 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2144 MDIWindow * w = getMDIWindow();
2151 if (w->slotFileSaveAs(cancelled))
2155 name = w->getDocument()->getFilename();
2156 recentFiles->add(name);
2157 w->setWindowTitle(name);
2163 QMessageBox::information(this, QMessageBox::tr("Warning"),
2164 tr("Cannot save the file\n%1\nPlease check the permissions.")
2165 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2169 // updateRecentFilesMenu();
2170 recentFiles->UpdateGUI();
2172 QString message = tr("Saved drawing: %1").arg(name);
2173 statusBar()->showMessage(message, 2000);
2174 commandWidget->appendHistory(message);
2178 * Menu file -> export.
2180 void ApplicationWindow::slotFileExport()
2182 DEBUG->print("ApplicationWindow::slotFileExport()");
2183 statusBar()->showMessage(tr("Exporting drawing..."));
2184 MDIWindow * w = getMDIWindow();
2189 // read default settings:
2190 settings.beginGroup("Paths");
2191 QString defDir = settings.value("ExportImage", SYSTEM->getHomeDir()).toString();
2192 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2193 settings.endGroup();
2195 bool cancel = false;
2197 // Q3FileDialog fileDlg(NULL, "", true);
2198 QFileDialog fileDlg(NULL, "", "", "");
2200 #warning "Need to port to Qt4... !!! FIX !!!"
2202 Q3StrList f = QImageIO::outputFormats();
2203 QStringList formats = QStringList::fromStrList(f);
2204 QStringList filters;
2207 for (QStringList::Iterator it = formats.begin();
2208 it!=formats.end(); ++it)
2213 st = QString("%1 (*.%2 *.jpg)")
2214 .arg(QG_DialogFactory::extToFormat(*it))
2215 .arg(QString(*it).lower());
2219 st = QString("%1 (*.%2)")
2220 .arg(QG_DialogFactory::extToFormat(*it))
2221 .arg(QString(*it).lower());
2226 //if (!all.isEmpty()) {
2229 //all += QString("*.%1").arg(QString(*it).lower());
2232 QStringList filters;
2235 fileDlg.setFilters(filters);
2236 // fileDlg.setMode(Q3FileDialog::AnyFile);
2237 fileDlg.setFileMode(QFileDialog::AnyFile);
2238 // fileDlg.setCaption(QObject::tr("Export Image"));
2239 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2240 // fileDlg.setDir(defDir);
2241 fileDlg.setDirectory(defDir);
2242 fileDlg.selectNameFilter(defFilter);
2244 if (fileDlg.exec() == QDialog::Accepted)
2246 // fn = fileDlg.selectedFile();
2247 QStringList files = fileDlg.selectedFiles();
2249 if (!files.isEmpty())
2257 // store new default settings:
2260 settings.beginGroup("Paths");
2261 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2262 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2263 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2264 settings.endGroup();
2266 // find out extension:
2267 QString filter = fileDlg.selectedFilter();
2268 QString format = "";
2269 // int i = filter.find("(*.");
2270 int i = filter.indexOf("(*.");
2274 // int i2 = filter.find(QRegExp("[) ]"), i);
2275 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2276 format = filter.mid(i + 3, i2 - (i + 3));
2277 format = format.toUpper();
2280 // append extension to file:
2281 if (!QFileInfo(fn).fileName().contains("."))
2282 fn.append("." + format.toLower());
2284 // show options dialog:
2285 ImageOptionsDialog dlg(this);
2286 dlg.setGraphicSize(w->getGraphic()->getSize());
2290 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2294 QString message = tr("Exported: %1").arg(fn);
2295 statusBar()->showMessage(message, 2000);
2296 commandWidget->appendHistory(message);
2304 * Exports the drawing as a bitmap.
2306 * @param name File name.
2307 * @param format File format (e.g. "png")
2308 * @param size Size of the bitmap in pixel
2309 * @param black true: Black background, false: white
2310 * @param bw true: black/white export, false: color
2312 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2314 MDIWindow * w = getMDIWindow();
2318 DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2322 Drawing * graphic = w->getDocument()->getGraphic();
2326 DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2330 statusBar()->showMessage(tr("Exporting..."));
2331 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2334 QPixmap * buffer = new QPixmap(size);
2335 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2336 QPainter qpntr(buffer);
2337 PaintInterface * painter = new PaintInterface(&qpntr);
2339 // black background:
2341 // painter->setBackgroundColor(Color(0, 0, 0));
2342 // qpntr.setBackgroundColor(Color(0, 0, 0));
2343 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2344 // white background:
2346 // painter->setBackgroundColor(Color(255, 255, 255));
2347 // qpntr.setBackgroundColor(Color(255, 255, 255));
2348 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2352 painter->setDrawingMode(RS2::ModeBW);
2354 // painter->eraseRect(0, 0, size.width(), size.height());
2355 qpntr.eraseRect(0, 0, size.width(), size.height());
2357 StaticGraphicView gv(size.width(), size.height(), painter);
2360 gv.setBackground(Color(0, 0, 0));
2362 gv.setBackground(Color(255, 255, 255));
2364 gv.setContainer(graphic);
2366 gv.drawEntity(graphic, true);
2373 iio.setFileName(name);
2374 iio.setFormat(format);
2381 #warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!"
2384 QApplication::restoreOverrideCursor();
2386 // GraphicView deletes painter
2393 statusBar()->showMessage(tr("Export complete"), 2000);
2395 statusBar()->showMessage(tr("Export failed!"), 2000);
2401 * Menu file -> close.
2403 void ApplicationWindow::slotFileClose()
2405 DEBUG->print("ApplicationWindow::slotFileClose()");
2407 MDIWindow * m = getMDIWindow();
2416 //m->showMaximized();
2417 m->setWindowState(WindowMaximized);
2423 * Called when a MDI window is actually about to close. Used to
2424 * detach widgets from the document.
2426 void ApplicationWindow::slotFileClosing()
2428 DEBUG->print("ApplicationWindow::slotFileClosing()");
2430 DEBUG->print("detaching lists");
2431 layerWidget->setLayerList(NULL, false);
2432 blockWidget->setBlockList(NULL);
2433 coordinateWidget->setGraphic(NULL);
2435 simulationControls->setGraphicView(NULL);
2440 * Menu file -> print.
2442 void ApplicationWindow::slotFilePrint()
2444 DEBUG->print("ApplicationWindow::slotFilePrint()");
2446 MDIWindow * w = getMDIWindow();
2450 DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2454 Drawing * graphic = w->getDocument()->getGraphic();
2456 if (graphic == NULL)
2458 DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2462 statusBar()->showMessage(tr("Printing..."));
2463 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2464 bool landscape = false;
2465 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2468 printer->setOrientation(QPrinter::Landscape);
2470 printer->setOrientation(QPrinter::Portrait);
2472 settings.beginGroup("Print");
2473 printer->setOutputFileName(settings.value("FileName", "").toString());
2474 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2475 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2476 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2477 settings.endGroup();
2480 // if (printer->setup(this))
2481 QPrintDialog dialog(printer, this);
2485 //printer->setOutputToFile(true);
2486 //printer->setOutputFileName(outputFile);
2488 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2489 printer->setFullPage(true);
2490 //Can call these functions directly from the QPaintDevice...
2491 // Q3PaintDeviceMetrics metr(printer);
2493 // RS_PainterQt * painter = new RS_PainterQt(printer);
2494 QPainter qpntr(printer);
2495 PaintInterface * painter = new PaintInterface(&qpntr);
2496 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2498 // StaticGraphicView gv(metr.width(), metr.height(), painter);
2499 StaticGraphicView gv(printer->width(), printer->height(), painter);
2500 gv.setPrinting(true);
2501 gv.setBorders(0, 0, 0, 0);
2503 // double fx = (double)metr.width() / metr.widthMM() * Units::getFactorToMM(graphic->getUnit());
2504 // double fy = (double)metr.height() / metr.heightMM() * Units::getFactorToMM(graphic->getUnit());
2505 double fx = (double)printer->width() / printer->widthMM() * Units::getFactorToMM(graphic->getUnit());
2506 double fy = (double)printer->height() / printer->heightMM() * Units::getFactorToMM(graphic->getUnit());
2507 double f = (fx + fy) / 2;
2508 double scale = graphic->getPaperScale();
2510 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2511 (int)(graphic->getPaperInsertionBase().y * f));
2512 gv.setFactor(f * scale);
2513 gv.setContainer(graphic);
2514 gv.drawEntity(graphic, true);
2516 // GraphicView deletes painter
2521 settings.beginGroup("Print");
2522 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2523 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2524 settings.setValue("ColorMode", (int)printer->colorMode());
2525 settings.setValue("FileName", printer->outputFileName());
2526 settings.endGroup();
2527 QApplication::restoreOverrideCursor();
2532 statusBar()->showMessage(tr("Printing complete"), 2000);
2536 * Menu file -> print preview.
2538 void ApplicationWindow::slotFilePrintPreview(bool on)
2540 DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2542 DEBUG->print(" creating MDI window");
2543 MDIWindow * parent = getMDIWindow();
2547 DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2551 // close print preview:
2554 DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2556 if (parent->getGraphicView()->isPrintPreview())
2558 DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2562 // open print preview:
2565 // look for an existing print preview:
2566 MDIWindow * ppv = parent->getPrintPreview();
2570 DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2571 slotWindowActivated(ppv);
2576 if (!parent->getGraphicView()->isPrintPreview())
2578 DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2580 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2581 w->setAttribute(Qt::WA_DeleteOnClose);
2582 parent->addChildWindow(w);
2583 //connect(w, SIGNAL(signalClosing()),
2584 // this, SLOT(slotFileClosing()));
2586 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2587 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2588 // w->setIcon(qPixmapFromMimeSource("document.png"));
2589 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2590 w->setWindowIcon(QIcon(":/res/document.png"));
2591 w->getGraphicView()->setPrintPreview(true);
2592 w->getGraphicView()->setBackground(Color(255, 255, 255));
2593 w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2595 // only graphics offer block lists, blocks don't
2596 DEBUG->print(" adding listeners");
2597 Drawing * graphic = w->getDocument()->getGraphic();
2602 // Link the layer list to the pen tool bar
2603 graphic->addLayerListListener(penToolBar);
2604 // Link the layer list to the layer widget
2605 graphic->addLayerListListener(layerWidget);
2606 // Link the block list to the block widget
2607 graphic->addBlockListListener(blockWidget);
2609 // Center by default:
2610 graphic->centerToPage();
2613 // Link the graphic view to the mouse widget:
2614 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2615 // Link the graphic view to the coordinate widget:
2616 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2617 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2618 // Link the graphic view to the option widget:
2619 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2620 // Link the graphic view to the cad tool bar:
2621 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2622 // Link the graphic view to the command widget:
2623 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2625 DEBUG->print(" showing MDI window");
2627 if (workspace->subWindowList().isEmpty())
2632 w->getGraphicView()->zoomPage();
2635 slotWindowActivated(w);
2642 * Menu file -> quit.
2644 void ApplicationWindow::slotFileQuit()
2646 DEBUG->print("ApplicationWindow::slotFileQuit()");
2648 statusBar()->showMessage(tr("Exiting application..."));
2650 if (queryExit(false))
2656 * Forces termination of QCad (demo version).
2658 void ApplicationWindow::slotFileDemoQuit()
2660 statusBar()->showMessage(tr("Exiting application..."));
2668 * Shows / hides the grid.
2670 * @param toggle true: show, false: hide.
2672 void ApplicationWindow::slotViewGrid(bool toggle)
2674 DEBUG->print("ApplicationWindow::slotViewGrid()");
2676 MDIWindow * m = getMDIWindow();
2680 Drawing * g = m->getGraphic();
2683 g->setGridOn(toggle);
2689 DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2693 * Enables / disables the draft mode.
2695 * @param toggle true: enable, false: disable.
2697 void ApplicationWindow::slotViewDraft(bool toggle)
2699 DEBUG->print("ApplicationWindow::slotViewDraft()");
2701 /*MDIWindow* m = getMDIWindow();
2703 Drawing* g = m->getGraphic();
2705 g->setDraftOn(toggle);
2709 settings.beginGroup("Appearance");
2710 settings.setValue("DraftMode", toggle);
2711 settings.endGroup();
2717 * Redraws all mdi windows.
2719 void ApplicationWindow::redrawAll()
2723 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2725 for(int i=0; i<int(windows.count()); ++i)
2727 MDIWindow * m = (MDIWindow *)windows.at(i);
2731 QG_GraphicView * gv = m->getGraphicView();
2741 * Updates all grids of all graphic views.
2743 void ApplicationWindow::updateGrids()
2747 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2749 for(int i=0; i<int(windows.count()); ++i)
2751 MDIWindow * m = (MDIWindow *)windows.at(i);
2755 QG_GraphicView * gv = m->getGraphicView();
2765 * Shows / hides the status bar.
2767 * @param showSB true: show, false: hide.
2769 void ApplicationWindow::slotViewStatusBar(bool showSB)
2771 DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2774 statusBar()->show();
2776 statusBar()->hide();
2780 * Shows / hides the layer list.
2782 * @param toggle true: show, false: hide.
2784 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2785 DEBUG->print("ApplicationWindow::slotViewLayerList()");
2787 if (toggle==false) {
2788 layerDockWindow->hide();
2790 layerDockWindow->show();
2796 * Shows / hides the block list.
2798 * @param toggle true: show, false: hide.
2801 void ApplicationWindow::slotViewBlockList(bool toggle) {
2802 DEBUG->print("ApplicationWindow::slotViewBlockList()");
2804 if (toggle==false) {
2805 blockDockWindow->hide();
2807 blockDockWindow->show();
2813 * Shows / hides the command line.
2815 * @param toggle true: show, false: hide.
2818 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2819 DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2821 if (toggle==false) {
2822 commandDockWindow->hide();
2823 //QG_GraphicView* graphicView = getGraphicView();
2824 //if (graphicView!=NULL) {
2825 //graphicView->setFocus();
2829 commandDockWindow->show();
2835 * Shows / hides the option toolbar.
2837 * @param toggle true: show, false: hide.
2840 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2841 DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2843 if (toggle==false) {
2844 optionWidget->hide();
2846 optionWidget->show();
2852 * Creates a new MDI window for editing the selected block.
2855 void ApplicationWindow::slotBlocksEdit() {
2856 DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2858 MDIWindow* parent = getMDIWindow();
2860 BlockList* blist = blockWidget->getBlockList();
2862 Block* blk = blist->getActiveBlock();
2864 MDIWindow* w = slotFileNew(blk);
2865 // the parent needs a pointer to the block window and
2867 parent->addChildWindow(w);
2868 w->getGraphicView()->zoomAuto();
2876 * Shows the dialog for general application preferences.
2878 void ApplicationWindow::slotOptionsGeneral()
2880 DIALOGFACTORY->requestOptionsGeneralDialog();
2882 // update background color of all open drawings:
2883 settings.beginGroup("Appearance");
2884 QColor color(settings.value("BackgroundColor", "#000000").toString());
2885 QColor gridColor(settings.value("GridColor", "Gray").toString());
2886 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2887 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2888 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2889 settings.endGroup();
2891 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2893 for(int i=0; i<int(windows.count()); ++i)
2895 MDIWindow * m = (MDIWindow *)windows.at(i);
2899 QG_GraphicView * gv = m->getGraphicView();
2903 gv->setBackground(color);
2904 gv->setGridColor(gridColor);
2905 gv->setMetaGridColor(metaGridColor);
2906 gv->setSelectedColor(selectedColor);
2907 gv->setHighlightedColor(highlightedColor);
2916 * Menu script -> show ide
2918 void ApplicationWindow::slotScriptOpenIDE()
2921 scripter->openIDE();
2926 * Menu script -> run
2928 void ApplicationWindow::slotScriptRun()
2931 scripter->runScript();
2936 * Menu help -> about.
2938 void ApplicationWindow::slotHelpAbout()
2940 DEBUG->print("ApplicationWindow::slotHelpAbout()");
2941 QStringList modules;
2948 modules += "Scripting";
2951 QString modulesString;
2953 if (!modules.empty())
2954 modulesString = modules.join(", ");
2956 modulesString = tr("None");
2958 QMessageBox box(this);
2959 box.setWindowTitle(tr("About..."));
2960 box.setText(QString("<qt>") + // no center for main stream QCad
2961 #ifdef QC_ABOUT_HEADER
2962 QString("<center>") +
2963 QString(QC_ABOUT_HEADER) +
2965 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2966 "<h2>Architektonas</h2>" +
2968 tr("Version: %1").arg("1.0.0") + "<br>" +
2969 tr("Date: %1").arg(__DATE__) + "<br>" +
2970 QString("© 2010 Underground Software,<br>James Hammons") +
2972 QString("Portions © 2001-2003 RibbonSoft") +
2974 #ifdef QC_ABOUT_ADD_COMPANY
2975 + QString("<br>") + QC_ABOUT_ADD_COMPANY
2977 + QString("</center>")
2979 #ifndef QC_ABOUT_HEADER
2980 #warning "Failure..."
2981 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
2982 box.setFixedWidth(340);
2983 box.setFixedHeight(250);
2989 * Menu help -> help.
2991 void ApplicationWindow::slotHelpManual()
2993 #warning "No help system ported to Qt4... !!! FIX !!!"
2995 DEBUG->print("ApplicationWindow::slotHelpManual()");
2997 if (assistant == NULL)
2999 DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", SYSTEM->getAppDir().toLatin1().data());
3000 DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", SYSTEM->getAppDir().toLatin1().data());
3001 assistant = new QAssistantClient(SYSTEM->getAppDir()+"/bin", this);
3002 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3005 args << QDir::convertSeparators(SYSTEM->getDocPath() + "/qcaddoc.adp");
3006 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3008 #if QT_VERSION>=0x030200
3009 assistant->setArguments(args);
3012 assistant->openAssistant();
3013 //assistant->showPage("index.html");
3020 void ApplicationWindow::slotTestDumpEntities(EntityContainer * d)
3022 DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3023 static int level = 0;
3024 std::ofstream dumpFile;
3029 dumpFile.open("debug_entities.html");
3034 dumpFile.open("debug_entities.html", std::ios::app);
3042 dumpFile << "<html>\n";
3043 dumpFile << "<body>\n";
3046 for (Entity* e=d->firstEntity();
3051 dumpFile << "<table border=\"1\">\n";
3052 dumpFile << "<tr><td>Entity: " << e->getId()
3056 << "<tr><td><table><tr>"
3057 << "<td>VIS:" << e->isVisible() << "</td>"
3058 << "<td>UND:" << e->isUndone() << "</td>"
3059 << "<td>SEL:" << e->isSelected() << "</td>"
3060 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3061 QString lay = "NULL";
3062 if (e->getLayer()!=NULL) {
3063 lay = e->getLayer()->getName();
3066 //fail << "<td>Layer: " << lay << "</td>"
3067 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3068 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3076 case RS2::EntityPoint:
3078 Point* p = (Point*)e;
3080 << "<table><tr><td>"
3092 case RS2::EntityLine:
3096 << "<table><tr><td>"
3102 << l->getStartpoint()
3111 case RS2::EntityArc: {
3114 << "<table><tr><td>"
3131 << "<td>Startpoint: "
3132 << a->getStartpoint()
3138 << (int)a->isReversed()
3144 case RS2::EntityCircle: {
3145 Circle* c = (Circle*)e;
3147 << "<table><tr><td>"
3162 case RS2::EntityDimAligned: {
3163 DimAligned* d = (DimAligned*)e;
3165 << "<table><tr><td>"
3166 << "<b>Dimension / Aligned:</b>"
3171 << d->getDefinitionPoint()
3174 << d->getExtensionPoint1()
3177 << d->getExtensionPoint2()
3180 << d->getText().toLatin1().data()
3183 << d->getLabel().toLatin1().data()
3189 case RS2::EntityDimLinear:
3191 DimLinear* d = (DimLinear*)e;
3193 << "<table><tr><td>"
3194 << "<b>Dimension / Linear:</b>"
3199 << d->getDefinitionPoint()
3202 << d->getExtensionPoint1()
3205 << d->getExtensionPoint2()
3208 //fail << d->getText()
3211 //fail << d->getLabel()
3217 case RS2::EntityInsert: {
3218 Insert* i = (Insert*)e;
3220 << "<table><tr><td>"
3225 << "<td>Insertion point:"
3226 << i->getInsertionPoint()
3232 case RS2::EntityText: {
3235 << "<table><tr><td>"
3241 << t->getText().toLatin1().data()
3250 case RS2::EntityHatch: {
3251 Hatch* h = (Hatch*)e;
3253 << "<table><tr><td>"
3259 << h->getPattern().toLatin1().data()
3265 << (int)h->isSolid()
3274 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3279 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3280 EntityContainer* ec = (EntityContainer*)e;
3281 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3283 slotTestDumpEntities(ec);
3284 dumpFile.open("debug_entities.html", std::ios::app);
3285 dumpFile << "</td></tr></table>\n";
3295 dumpFile << "</body>\n";
3296 dumpFile << "</html>\n";
3306 void ApplicationWindow::slotTestDumpUndo()
3308 DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3310 Document * d = getDocument();
3314 std::cout << *(Undo*)d;
3315 std::cout << std::endl;
3322 void ApplicationWindow::slotTestUpdateInserts()
3324 DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3326 Document * d = getDocument();
3335 void ApplicationWindow::slotTestDrawFreehand()
3337 DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3339 //Drawing* g = document->getMarking();
3342 ActionDrawLineFree* action =
3343 new ActionDrawLineFree(*document->getGraphic(),
3346 for (int i=0; i<100; ++i) {
3348 int posx = (random()%600);
3349 int posy = (random()%400);
3351 //RS_MouseEvent rsm1(posx, posy, LEFT);
3352 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3356 action->mousePressEvent(&rsm1);
3361 for (int k=0; k<100; ++k) {
3362 int accx = (random()%40)-20;
3363 int accy = (random()%40)-20;
3371 //RS_MouseEvent rsm2(posx, posy, LEFT);
3373 RS_MouseEvent rsm2(QEvent::MouseMove,
3377 action->mouseMoveEvent(&rsm2);
3380 action->mouseReleaseEvent(NULL);
3392 void ApplicationWindow::slotTestInsertBlock()
3394 DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3396 Document * d = getDocument();
3398 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3400 Drawing * graphic = (Drawing *)d;
3402 if (graphic == NULL)
3405 graphic->addLayer(new Layer("default"));
3406 Block * block = new Block(graphic, BlockData("debugblock", Vector(0.0, 0.0), true));
3412 // Add one red line:
3413 line = new Line(block, LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3414 line->setLayerToActive();
3415 line->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3416 block->addEntity(line);
3418 // Add one line with attributes from block:
3419 line = new Line(block, LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3420 line->setPen(Pen(Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3421 block->addEntity(line);
3423 // Add one arc with attributes from block:
3424 ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3425 arc = new Arc(block, d);
3426 arc->setPen(Pen(Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3427 block->addEntity(arc);
3429 // Add one blue circle:
3430 CircleData circleData(Vector(20.0, 15.0), 12.5);
3431 circle = new Circle(block, circleData);
3432 circle->setLayerToActive();
3433 circle->setPen(Pen(Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3434 block->addEntity(circle);
3436 graphic->addBlock(block);
3439 InsertData insData("debugblock", Vector(0.0, 0.0), Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3441 // insert one magenta instance of the block (original):
3442 ins = new Insert(graphic, insData);
3443 ins->setLayerToActive();
3444 ins->setPen(Pen(Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3446 graphic->addEntity(ins);
3448 // insert one green instance of the block (rotate):
3449 insData = InsertData("debugblock", Vector(-50.0, 20.0), Vector(1.0, 1.0), 30.0 / ARAD, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3450 ins = new Insert(graphic, insData);
3451 ins->setLayerToActive();
3452 ins->setPen(Pen(Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3454 graphic->addEntity(ins);
3456 // insert one cyan instance of the block (move):
3457 insData = InsertData("debugblock", Vector(10.0, 20.0), Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3458 ins = new Insert(graphic, insData);
3459 ins->setLayerToActive();
3460 ins->setPen(Pen(Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3462 graphic->addEntity(ins);
3464 // insert one blue instance of the block:
3465 for(double a=0.0; a<360.0; a+=45.0)
3467 insData = InsertData("debugblock", Vector(60.0, 0.0), Vector(2.0 / 5, 2.0 / 5), a/ARAD, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3468 ins = new Insert(graphic, insData);
3469 ins->setLayerToActive();
3470 ins->setPen(Pen(Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3472 graphic->addEntity(ins);
3475 // insert an array of yellow instances of the block:
3476 insData = InsertData("debugblock", Vector(-100.0, -100.0), Vector(0.2, 0.2), M_PI / 6.0, 6, 4, Vector(100.0, 100.0), NULL, RS2::NoUpdate);
3477 ins = new Insert(graphic, insData);
3478 ins->setLayerToActive();
3479 ins->setPen(Pen(Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3481 graphic->addEntity(ins);
3483 GraphicView * v = getGraphicView();
3493 void ApplicationWindow::slotTestInsertEllipse()
3495 DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3497 Document * d = getDocument();
3501 Drawing * graphic = (Drawing *)d;
3503 if (graphic == NULL)
3509 for (double a=0.0; a<2*M_PI; a+=0.1)
3512 v.setPolar(50.0, a);
3513 double xp = 1000.0*a;
3515 EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3516 ellipse = new Ellipse(graphic, ellipseData);
3518 ellipse->setPen(Pen(Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3520 graphic->addEntity(ellipse);
3521 //graphic->addEntity(new Point(graphic, ellipse->getMax()));
3522 //graphic->addEntity(new Point(graphic, ellipse->getMin()));
3524 line = new Line(graphic, LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3525 line->setPen(Pen(Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3526 graphic->addEntity(line);
3529 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3530 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3531 VectorSolutions sol = ellipse->mapX(xp + mx);
3532 //graphic->addEntity(new Point(graphic,
3533 // sol.vector2 + Vector(a*500.0, 0.0)));
3534 //graphic->addEntity(new Point(graphic,
3535 // sol.vector3 + Vector(a*500.0, 0.0)));
3536 //graphic->addEntity(new Point(graphic,
3537 // sol.vector4 + Vector(a*500.0, 0.0)));
3539 line = new Line(graphic,
3540 LineData(Vector(xp+mx,-50.0),
3541 Vector(xp+mx,50.0)));
3542 line->setPen(Pen(Color(60, 60, 60),
3545 graphic->addEntity(line);
3547 graphic->addEntity(new Point(graphic,
3553 // different minor/minor relations
3556 for (y=-250.0; y<=250.0; y+=50.0) {
3557 for (x=-250.0; x<=250.0; x+=50.0) {
3560 ellipse = new Ellipse(graphic,
3562 Vector((x/5+50.0)/2.0, 0.0),
3567 ellipse->setPen(Pen(Color(255, 255, 0),
3571 graphic->addEntity(ellipse);
3572 graphic->addEntity(new Point(graphic, ellipse->getMax()));
3573 graphic->addEntity(new Point(graphic, ellipse->getMin()));
3575 ellipse = new Ellipse(graphic,
3576 v + Vector(750.0, 0.0),
3577 Vector((x/5+50.0)/2.0, 0.0),
3582 graphic->addEntity(ellipse);
3583 graphic->addEntity(new Point(graphic, ellipse->getMax()));
3584 graphic->addEntity(new Point(graphic, ellipse->getMin()));
3590 // different rotation angles:
3592 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3593 ellipse = new Ellipse(graphic,
3594 Vector(rot*200, 500.0),
3595 Vector(50.0, 0.0).rotate(rot),
3599 graphic->addEntity(ellipse);
3600 graphic->addEntity(new Point(graphic, ellipse->getMax()));
3601 graphic->addEntity(new Point(graphic, ellipse->getMin()));
3605 // different arc angles:
3607 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3608 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3609 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3610 ellipse = new Ellipse(graphic,
3611 Vector(-500.0-a1*200.0-5000.0*rot,
3613 Vector(50.0, 0.0).rotate(rot),
3617 graphic->addEntity(ellipse);
3618 graphic->addEntity(new Point(graphic, ellipse->getMax()));
3619 graphic->addEntity(new Point(graphic, ellipse->getMin()));
3625 GraphicView * v = getGraphicView();
3635 void ApplicationWindow::slotTestInsertText()
3637 DEBUG->print("ApplicationWindow::slotTestInsertText()");
3639 Document * d = getDocument();
3643 Drawing * graphic = (Drawing *)d;
3645 if (graphic == NULL)
3651 textData = TextData(Vector(10.0, 10.0), 10.0, 100.0, RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, "Andrew", "normal", 0.0);
3652 text = new Text(graphic, textData);
3653 text->setLayerToActive();
3654 text->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3655 graphic->addEntity(text);
3659 for (y=-250.0; y<=250.0; y+=50.0) {
3660 for (x=-250.0; x<=250.0; x+=50.0) {
3663 textData = TextData(v,
3674 text = new Text(graphic, textData);
3676 text->setLayerToActive();
3677 text->setPen(Pen(Color(255, 0, 0),
3680 graphic->addEntity(text);
3685 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3686 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3688 line = new Line(graphic,
3689 LineData(Vector(600.0,0.0),
3691 line->setLayerToActive();
3692 line->setPenToActive();
3693 graphic->addEntity(line);
3695 textData = TextData(v,
3706 text = new Text(graphic, textData);
3708 text->setLayerToActive();
3709 text->setPen(Pen(Color(255, 0, 0),
3712 graphic->addEntity(text);
3715 SolidData solidData = SolidData(Vector(5.0, 10.0),
3717 Vector(15.0, 30.0));
3719 Solid* s = new Solid(graphic, solidData);
3721 s->setLayerToActive();
3722 s->setPen(Pen(Color(255, 255, 0),
3725 graphic->addEntity(s);
3727 GraphicView* v = getGraphicView();
3738 void ApplicationWindow::slotTestInsertImage()
3740 DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3742 Document * d = getDocument();
3746 Drawing * graphic = (Drawing *)d;
3748 if (graphic == NULL)
3752 ImageData imageData;
3754 imageData = ImageData(0, Vector(50.0, 30.0), Vector(0.5, 0.5), Vector(-0.5, 0.5), Vector(640, 480), "/home/andrew/data/image.png", 50, 50, 0);
3755 image = new Image(graphic, imageData);
3757 image->setLayerToActive();
3758 image->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3759 graphic->addEntity(image);
3766 void ApplicationWindow::slotTestUnicode()
3768 DEBUG->print("ApplicationWindow::slotTestUnicode()");
3770 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3771 Document* d = getDocument();
3773 Drawing* graphic = (Drawing*)d;
3774 if (graphic==NULL) {
3782 QChar uCode; // e.g. 65 (or 'A')
3783 QString strCode; // unicde as string e.g. '[0041] A'
3785 graphic->setAutoUpdateBorders(false);
3787 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3788 printf("col: %X\n", col);
3789 for (row=0x0; row<=0xF; row++) {
3790 //printf(" row: %X\n", row);
3792 uCode = QChar(col+row);
3793 //printf(" code: %X\n", uCode.unicode());
3795 strCode.setNum(uCode.unicode(), 16);
3796 while (strCode.length()<4) {
3797 strCode="0"+strCode;
3799 strCode = "[" + strCode + "] " + uCode;
3801 if (graphic->findBlock(strCode)!=NULL) {
3802 InsertData d(strCode,
3803 Vector(col/0x10*20.0,row*20.0),
3804 Vector(1.0,1.0), 0.0,
3805 1, 1, Vector(0.0, 0.0),
3806 NULL, RS2::NoUpdate);
3807 ins = new Insert(graphic, d);
3808 ins->setLayerToActive();
3809 ins->setPen(Pen(Color(255, 255, 255),
3813 graphic->addEntity(ins);
3817 graphic->setAutoUpdateBorders(true);
3818 graphic->calculateBorders();
3825 void ApplicationWindow::slotTestMath01()
3827 DEBUG->print("ApplicationWindow::slotTestMath01()");
3829 Document* d = getDocument();
3831 Drawing* graphic = (Drawing*)d;
3832 if (graphic==NULL) {
3837 graphic->addEntity(new Line(graphic,
3838 LineData(Vector(0.0,0.0),
3839 Vector(2*M_PI,0.0))));
3840 graphic->addEntity(new Line(graphic,
3841 LineData(Vector(0.0,-1.0),
3846 double x = 59.0/ARAD;
3847 double x_0 = 60.0/ARAD;
3848 for (a=0.01; a<2*M_PI; a+=0.01) {
3850 Line* line = new Line(graphic,
3851 LineData(Vector(a-0.01, cos(a-0.01)),
3852 Vector(a, cos(a))));
3853 graphic->addEntity(line);
3856 graphic->addEntity(new Line(graphic,
3857 LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3858 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3862 graphic->addEntity(new Line(graphic,
3863 LineData(Vector(x,0.0),
3867 graphic->addEntity(new Line(graphic,
3868 LineData(Vector(x_0,0.0),
3872 //graphic->addEntity(new Line(graphic,
3873 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3874 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3877 GraphicView* v = getGraphicView();
3887 void ApplicationWindow::slotTestResize640()
3889 DEBUG->print("ApplicationWindow::slotTestResize640()");
3897 void ApplicationWindow::slotTestResize800()
3899 DEBUG->print("ApplicationWindow::slotTestResize800()");
3907 void ApplicationWindow::slotTestResize1024()
3909 DEBUG->print("ApplicationWindow::slotTestResize1024()");
3915 * overloaded for Message box on last window exit.
3917 bool ApplicationWindow::queryExit(bool force)
3919 DEBUG->print("ApplicationWindow::queryExit()");
3926 QMessageBox::information(this, QMessageBox::tr("Warning"),
3927 tr("This is a %1 version "
3928 "which terminates\n"
3929 "automatically after 10min. This software is\n"
3930 "not intended for production use. Please buy\n"
3931 "a full version of the application from\n%2.\n"
3932 "You can save your work now.")
3933 //FAIL .arg(QC_APPNAME)
3934 .arg("Architektonas")
3935 #ifdef QC_CUSTOM_VENDOR
3936 .arg(QC_CUSTOM_VENDOR),
3938 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3943 QList<QMdiSubWindow *> list = workspace->subWindowList();
3945 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3946 for(int i=0; i<list.size(); i++)
3948 succ = ((MDIWindow *)list[i])->closeMDI(force);
3957 DEBUG->print("ApplicationWindow::queryExit(): OK");
3963 * Handle hotkeys. Don't let it to the default handler of Qt.
3964 * it will consume them also if a text field is active
3965 * which means it's impossible to enter a command.
3967 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3969 #warning "!!! keyPressEvent(): Do we need this anymore? !!!"
3971 static QTime ts = QTime();
3972 static QString firstKey = "";
3974 // single key codes:
3978 case Qt::Key_Control:
3981 case Qt::Key_CapsLock:
3983 QMainWindow::keyPressEvent(e);
3985 // forward to actions:
3986 GraphicView * graphicView = getGraphicView();
3989 graphicView->keyPressEvent(e);
3995 case Qt::Key_Escape:
4001 case Qt::Key_Return:
4002 if (firstKey.isEmpty())
4010 if (firstKey.isEmpty())
4012 actionHandler->slotZoomIn();
4018 if (firstKey.isEmpty())
4020 actionHandler->slotZoomOut();
4030 if (e->isAccepted())
4033 QTime now = QTime::currentTime();
4036 if (ts.msecsTo(now) < 2000)
4038 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4040 if (actionHandler->keycode(code) == false)
4044 if (QChar(e->key()).isPrint())
4045 firstKey += e->key();
4054 if (QChar(e->key()).isPrint())
4055 firstKey = e->key();
4058 // Q3MainWindow::keyPressEvent(e);
4059 QMainWindow::keyPressEvent(e);
4062 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4067 case Qt::Key_Control:
4070 case Qt::Key_CapsLock:
4072 // Q3MainWindow::keyReleaseEvent(e);
4073 QMainWindow::keyReleaseEvent(e);
4075 // forward to actions:
4076 GraphicView * graphicView = getGraphicView();
4079 graphicView->keyReleaseEvent(e);
4086 // Q3MainWindow::keyPressEvent(e);
4087 QMainWindow::keyPressEvent(e);
4091 * @return Pointer to application window.
4093 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4099 * @return Pointer to workspace.
4101 QMdiArea * ApplicationWindow::getWorkspace()
4107 * @return Pointer to the currently active MDI Window or NULL if no
4108 * MDI Window is active.
4110 MDIWindow * ApplicationWindow::getMDIWindow()
4112 DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4116 DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4117 return (MDIWindow *)workspace->activeSubWindow();
4120 DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4125 * Implementation from MainWindowInterface (and QS_ScripterHostInterface).
4127 * @return Pointer to the graphic view of the currently active document
4128 * window or NULL if no window is available.
4130 /*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
4132 MDIWindow * m = getMDIWindow();
4134 return (m ? m->getGraphicView() : NULL);
4138 * Implementation from MainWindowInterface (and QS_ScripterHostInterface).
4140 * @return Pointer to the graphic document of the currently active document
4141 * window or NULL if no window is available.
4143 /*virtual*/ Document * ApplicationWindow::getDocument()
4145 MDIWindow * m = getMDIWindow();
4147 return (m ? m->getDocument() : NULL);
4151 * Creates a new document. Implementation from MainWindowInterface.
4153 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4154 Document * doc/*= NULL*/)
4158 if (fileName != QString::null && getDocument())
4159 getDocument()->setFilename(fileName);
4163 * Implementation from QG_MainWindowInterface.
4165 * @return Pointer to this.
4167 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4173 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4175 /*virtual*/ ActionHandler * ApplicationWindow::getActionHandler()
4177 return actionHandler;
4181 * Implementation from QG_MainWindowInterface.
4183 /*virtual*/ void ApplicationWindow::showSimulationControls()
4186 simulationDockWindow->show();
4192 * @return Pointer to the qsa object.
4194 QSProject * ApplicationWindow::getQSAProject()
4196 if (scripter != NULL)
4197 return scripter->getQSAProject();
4204 * Implementation from QG_MainWindowInterface.
4206 /*virtual*/ void ApplicationWindow::setFocus2()