X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmainapp%2Fapplicationwindow.cpp;h=6a3fa71df35331dcba076281b1c42de222473744;hb=43c13b052d069ba435277d93867380d00c04931f;hp=61da6669ace723653860ff09da7b1fcbdeb6a28d;hpb=f62cebc26c7c3af447f0e4e4c43331f8589dce22;p=architektonas diff --git a/src/mainapp/applicationwindow.cpp b/src/mainapp/applicationwindow.cpp index 61da666..6a3fa71 100644 --- a/src/mainapp/applicationwindow.cpp +++ b/src/mainapp/applicationwindow.cpp @@ -19,6 +19,7 @@ #include "applicationwindow.h" #include +#include #include "actiondrawlinefree.h" #include "actionlibraryinsert.h" #include "actionprintpreview.h" @@ -65,33 +66,22 @@ #include "mdiwindow.h" ApplicationWindow * ApplicationWindow::appWindow = NULL; - -#ifndef QC_APP_ICON -# define QC_APP_ICON "qcad.png" -#endif -#ifndef QC_APP_ICON16 -# define QC_APP_ICON16 "qcad16.png" -#endif - extern QSplashScreen * splash; /** * Constructor. Initializes the app. */ ApplicationWindow::ApplicationWindow(): -// Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface() QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface() { DEBUG->print("ApplicationWindow::ApplicationWindow"); appWindow = this; -//no assistant = NULL; workspace = NULL; +#warning "!!! Need to create new application icon !!!" DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon"); -// setIcon(qPixmapFromMimeSource(QC_APP_ICON)); -// setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON)); - setWindowIcon(QIcon(":/res/" QC_APP_ICON)); + setWindowIcon(QIcon(":/res/qcad.png")); CreateQtActions(this); DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler"); @@ -119,25 +109,18 @@ ApplicationWindow::ApplicationWindow(): dialogFactory = new QC_DialogFactory(this, optionWidget); DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK"); DEBUG->print("setting dialog factory object"); - - if (DialogFactory::instance() == NULL) - DEBUG->print("no DialogFactory instance"); - else - DEBUG->print("got DialogFactory instance"); - + DEBUG->print("%s DialogFactory instance", (DialogFactory::instance() ? "got" : "no")); DialogFactory::instance()->setFactoryObject(dialogFactory); DEBUG->print("setting dialog factory object: OK"); DEBUG->print("ApplicationWindow::ApplicationWindow: init settings"); initSettings(); - DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI"); initMDI(); // Disable menu and toolbar items - emit windowsChanged(FALSE); + emit windowsChanged(false); -//FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000); statusBar()->showMessage("Architektonas Ready", 2000); //setFocusPolicy(WheelFocus); } @@ -161,14 +144,7 @@ ApplicationWindow::~ApplicationWindow() DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory"); delete dialogFactory; DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK"); - -//no DEBUG->print("ApplicationWindow::~ApplicationWindow: " -// "deleting assistant.."); -// if (assistant!=NULL) { -// delete assistant; -// } -// DEBUG->print("ApplicationWindow::~ApplicationWindow: " -// "deleting assistant: OK"); + DEBUG->print("ApplicationWindow::~ApplicationWindow: OK"); } @@ -404,7 +380,7 @@ void ApplicationWindow::initActions() menu->addAction(actionFilePrintPreview); tb->addAction(actionFilePrintPreview); connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool))); - connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool))); +//??? connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool))); connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool))); menu->addSeparator(); @@ -486,7 +462,7 @@ void ApplicationWindow::initActions() tb->addAction(actionViewGrid); actionViewGrid->setChecked(true); connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool))); - connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool))); +//??? connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool))); connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool))); settings.beginGroup("Appearance"); @@ -498,23 +474,9 @@ void ApplicationWindow::initActions() tb->addAction(actionViewDraft); actionViewDraft->setChecked(draftMode); connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool))); - connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool))); +//??? connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool))); connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool))); - /* - action = actionFactory.createAction(RS2::ActionViewLayerList, this); - action->addTo(menu); - action->setChecked(true); - action = actionFactory.createAction(RS2::ActionViewBlockList, this); - action->addTo(menu); - action->setChecked(true); - action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this); - action->addTo(menu); - action->setChecked(true); - action = actionFactory.createAction(RS2::ActionViewCommandLine, this); - action->addTo(menu); - action->setChecked(true);*/ - // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler); menu->addAction(actionZoomRedraw); tb->addAction(actionZoomRedraw); @@ -807,35 +769,27 @@ void ApplicationWindow::initActions() #endif menu = new QMenu(tr("&Dimension"), this); -// action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler); menu->addAction(actionDimAligned); connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned())); connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler); menu->addAction(actionDimLinear); connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler); menu->addAction(actionDimLinearHor); connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler); menu->addAction(actionDimLinearVer); connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler); menu->addAction(actionDimRadial); connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial())); connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler); menu->addAction(actionDimDiametric); connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric())); connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler); menu->addAction(actionDimAngular); connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular())); connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler); menu->addAction(actionDimLeader); connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool))); @@ -848,81 +802,60 @@ void ApplicationWindow::initActions() // Modifying actions: // menu = new QMenu(tr("&Modify"), this); -// action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler); menu->addAction(actionModifyMove); connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler); menu->addAction(actionModifyRotate); connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler); menu->addAction(actionModifyScale); connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler); menu->addAction(actionModifyMirror); connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler); menu->addAction(actionModifyMoveRotate); connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler); menu->addAction(actionModifyRotate2); connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler); menu->addAction(actionModifyTrim); connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler); menu->addAction(actionModifyTrim2); connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler); menu->addAction(actionModifyTrimAmount); connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler); menu->addAction(actionModifyBevel); connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler); menu->addAction(actionModifyRound); connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler); menu->addAction(actionModifyCut); connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler); menu->addAction(actionModifyStretch); connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler); menu->addAction(actionModifyEntity); connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler); menu->addAction(actionModifyAttributes); connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler); menu->addAction(actionModifyDelete); connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler); menu->addAction(actionModifyDeleteQuick); connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler); menu->addAction(actionModifyExplodeText); connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool))); -//// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler); -//// menu->addAction(action); -// action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler); menu->addAction(actionBlocksExplode); connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool))); @@ -931,48 +864,39 @@ void ApplicationWindow::initActions() // Snapping actions: // menu = new QMenu(tr("&Snap"), this); -// action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler); menu->addAction(actionSnapFree); actionHandler->setActionSnapFree(actionSnapFree); // ???Why??? connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool))); actionSnapFree->setChecked(true); -// action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler); menu->addAction(actionSnapGrid); actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why??? connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler); menu->addAction(actionSnapEndpoint); actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why??? connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler); menu->addAction(actionSnapOnEntity); actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why??? connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler); menu->addAction(actionSnapCenter); actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why??? connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler); menu->addAction(actionSnapMiddle); actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why??? connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler); menu->addAction(actionSnapDist); actionHandler->setActionSnapDist(actionSnapDist); // ???Why??? connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler); menu->addAction(actionSnapIntersection); actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why??? connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler); menu->addAction(actionSnapIntersectionManual); actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why??? connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual())); @@ -980,23 +904,19 @@ void ApplicationWindow::initActions() menu->addSeparator(); -// action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler); menu->addAction(actionRestrictNothing); actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY??? connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing())); connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool))); actionRestrictNothing->setChecked(true); -// action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler); menu->addAction(actionRestrictOrthogonal); actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY??? connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal())); connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler); menu->addAction(actionRestrictHorizontal); actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY??? connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal())); connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler); menu->addAction(actionRestrictVertical); actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY??? connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical())); @@ -1004,11 +924,9 @@ void ApplicationWindow::initActions() menu->addSeparator(); -// action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler); menu->addAction(actionSetRelativeZero); connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero())); connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler); menu->addAction(actionLockRelativeZero); actionHandler->setActionLockRelativeZero(actionLockRelativeZero); connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY??? @@ -1019,8 +937,6 @@ void ApplicationWindow::initActions() // Info actions: // menu = new QMenu(tr("&Info"), this); - //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler); - //menu->addAction(action); menu->addAction(actionInfoDist); connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist())); connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool))); @@ -1042,27 +958,21 @@ void ApplicationWindow::initActions() // Layer actions: // menu = new QMenu(tr("&Layer"), this); -// action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler); menu->addAction(actionLayersDefreezeAll); connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler); menu->addAction(actionLayersFreezeAll); connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler); menu->addAction(actionLayersAdd); connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler); menu->addAction(actionLayersRemove); connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler); menu->addAction(actionLayersEdit); connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler); menu->addAction(actionLayersToggleView); connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool))); @@ -1071,39 +981,30 @@ void ApplicationWindow::initActions() // Block actions: // menu = new QMenu(tr("&Block"), this); -// action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler); menu->addAction(actionBlocksDefreezeAll); connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler); menu->addAction(actionBlocksFreezeAll); connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler); menu->addAction(actionBlocksAdd); connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler); menu->addAction(actionBlocksRemove); connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler); menu->addAction(actionBlocksAttributes); connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler); menu->addAction(actionBlocksInsert); connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler); menu->addAction(actionBlocksEdit); connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler); menu->addAction(actionBlocksCreate); connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler); menu->addAction(actionBlocksExplode); connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool))); @@ -1144,7 +1045,7 @@ void ApplicationWindow::initActions() // Help menu: // - helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this); + helpAboutApp = new QAction(QIcon("qcad16.png"), tr("&About Architektonas"), this); // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this); helpAboutApp->setStatusTip(tr("About the application")); //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application")); @@ -1157,55 +1058,30 @@ void ApplicationWindow::initActions() connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual())); testDumpEntities = new QAction("Dump &Entities", this); -// testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this); connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities())); - testDumpUndo = new QAction("Undo Info", this); -// testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this); connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo())); - testUpdateInserts = new QAction("&Update Inserts", this); -// testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this); connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts())); - testDrawFreehand = new QAction("Draw Freehand", this); -// testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this); connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand())); - testInsertBlock = new QAction("Insert Block", this); -// testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this); connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock())); - testInsertText = new QAction("Insert Text", this); -// testInsertText = new QAction("Insert Text", "Insert Text", 0, this); connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText())); - testInsertImage = new QAction("Insert Image", this); -// testInsertImage = new QAction("Insert Image", "Insert Image", 0, this); connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage())); - testUnicode = new QAction("Unicode", this); -// testUnicode = new QAction("Unicode", "Unicode", 0, this); connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode())); - testInsertEllipse = new QAction("Insert Ellipse", this); -// testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this); connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse())); - testMath01 = new QAction("Math01", this); -// testMath01 = new QAction("Math01", "Math01", 0, this); connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01())); - testResize640 = new QAction("Resize 1", this); -// testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this); connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640())); - testResize800 = new QAction("Resize 2", this); -// testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this); connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800())); - testResize1024 = new QAction("Resize 3", this); -// testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this); connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024())); } @@ -1230,43 +1106,35 @@ void ApplicationWindow::initMenuBar() // menuBar entry helpMenu helpMenu = new QMenu(tr("&Help"), this); - helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu); - -// helpMenu->insertSeparator(helpManual); + helpMenu->addAction(helpManual); helpMenu->addSeparator(); - - helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu); + helpMenu->addAction(helpAboutApp); // menuBar entry test menu testMenu = new QMenu(tr("De&bugging"), this); - testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu); - testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu); - testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu); - testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu); - testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu); - testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu); - testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu); - testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu); - testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu); - testMenu->addAction(testMath01);//testMath01->addTo(testMenu); - testMenu->addAction(testResize640);//testResize640->addTo(testMenu); - testMenu->addAction(testResize800);//testResize800->addTo(testMenu); - testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu); + testMenu->addAction(testDumpEntities); + testMenu->addAction(testDumpUndo); + testMenu->addAction(testUpdateInserts); + testMenu->addAction(testDrawFreehand); + testMenu->addAction(testInsertBlock); + testMenu->addAction(testInsertText); + testMenu->addAction(testInsertImage); + testMenu->addAction(testInsertEllipse); + testMenu->addAction(testUnicode); + testMenu->addAction(testMath01); + testMenu->addAction(testResize640); + testMenu->addAction(testResize800); + testMenu->addAction(testResize1024); // menuBar configuration #ifdef SCRIPTING -// menuBar()->insertItem(tr("&Scripts"), scriptMenu); menuBar()->addMenu(scriptMenu); #endif -// menuBar()->insertItem(tr("&Window"), windowsMenu); menuBar()->addMenu(windowsMenu); #warning "!!!" -// menuBar()->insertSeparator(); -// menuBar()->insertItem(tr("&Help"), helpMenu); menuBar()->addMenu(helpMenu); if (QC_DEBUGGING) -// menuBar()->insertItem(tr("De&bugging"), testMenu); menuBar()->addMenu(testMenu); recentFiles = new RecentFiles(this, fileMenu); @@ -1279,13 +1147,10 @@ void ApplicationWindow::initToolBar() { DEBUG->print("ApplicationWindow::initToolBar()"); -// fileToolBar = new Q3ToolBar(this, "File Operations"); fileToolBar = addToolBar(tr("File Operations")); fileToolBar->setObjectName("file"); -// editToolBar = new Q3ToolBar(this, "Edit Operations"); editToolBar = addToolBar(tr("Edit Operations")); editToolBar->setObjectName("edit"); -// zoomToolBar = new Q3ToolBar(this, "Zoom Operations"); zoomToolBar = addToolBar(tr("Zoom Operations")); zoomToolBar->setObjectName("zoom"); penToolBar = new PenToolBar(this, "Pen Selection"); @@ -1341,17 +1206,19 @@ void ApplicationWindow::initStatusBar() DEBUG->print("ApplicationWindow::initStatusBar()"); statusBar()->setMinimumHeight(32); - coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates"); + coordinateWidget = new CoordinateWidget(statusBar()); statusBar()->addWidget(coordinateWidget); - mouseWidget = new MouseWidget(statusBar());//, "mouse info"); + mouseWidget = new MouseWidget(statusBar()); statusBar()->addWidget(mouseWidget); - selectionWidget = new SelectionWidget(statusBar());//, "selections"); + selectionWidget = new SelectionWidget(statusBar()); statusBar()->addWidget(selectionWidget); } /** * Initializes the global application settings from the * config file (unix, mac) or registry (windows). + * (Actually, this uses the Qt settings subsystem, so we don't have to worry + * about that crap.) */ void ApplicationWindow::initSettings() { @@ -1363,14 +1230,12 @@ void ApplicationWindow::initSettings() QString filename = settings.value(QString("File") + QString::number(i + 1)).toString(); if (!filename.isEmpty()) -// recentFiles->add(filename); recentFiles->add(filename); } settings.endGroup(); if (recentFiles->count() > 0) -// updateRecentFilesMenu(); recentFiles->UpdateGUI(); settings.beginGroup("Geometry"); @@ -1380,8 +1245,6 @@ void ApplicationWindow::initSettings() settings.endGroup(); #ifdef __APPLE__ -// if (windowY < 30) -// windowY = 30; if (windowSize.y() < 30) windowSize.y() = 30; #endif @@ -1529,30 +1392,6 @@ void ApplicationWindow::initView() DEBUG->print(" done"); } -/** - * Creates a new toolbar. - * Implementation from QG_MainWindowInterface. - * Can be called from scripts to add individual GUI elements. - */ -/*QToolBar* ApplicationWindow::createToolBar(const QString& name) { - QToolBar* tb = new QToolBar(this, name); - tb->setLabel(name); - return tb; -}*/ - -/** - * Creates a new button in the given tool bar for running a script. - */ -/*void ApplicationWindow::addToolBarButton(QToolBar* tb) { - if (tb!=NULL) { - QAction* action = new QAction("Blah", - QPixmap::fromMimeSource("zoomwindow.png"), - "&Blah", QKeySequence(), NULL); - action->setStatusTip("Blah blah"); - action->addTo(tb); - } -}*/ - /** * Goes back to the previous menu or one step in the current action. */ @@ -1606,35 +1445,33 @@ void ApplicationWindow::slotError(const QString & msg) } /** - * Hands focus back to the application window. In the rare event - * of a escape press from the layer widget (e.g after switching desktops - * in XP). + * Hands focus back to the application window. In the rare event of a escape + * press from the layer widget (e.g after switching desktops in XP). */ void ApplicationWindow::slotFocus() { - //QG_GraphicView* graphicView = getGraphicView(); - /*if (graphicView!=NULL) { - graphicView->setFocus(); -} - else {*/ setFocus(); - //} } /** * Called when a document window was activated. */ -void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) +//void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) +void ApplicationWindow::slotWindowActivated(QMdiSubWindow * sw) { +//This passes in a QMdiSubWindow, so why don't we use it??? +// Now, we do. :-) +//#warning "!!! ApplicationWindow::slotWindowActivated() ignores passed in value !!!" DEBUG->print("ApplicationWindow::slotWindowActivated begin"); //the following does: return (MDIWindow *)workspace->activeSubWindow(); //which means the subwindow is NOT being activated!!! - MDIWindow * m = getMDIWindow(); +// MDIWindow * m = getMDIWindow(); + MDIWindow * m = (MDIWindow *)sw; +// MDIWindow * m = (MDIWindow *)(sw->widget()); DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m); - - if (m) - DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument()); + DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", + (m ? m->getDocument() : 0)); if (m && m->getDocument()) { @@ -1644,17 +1481,19 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock; layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock); - coordinateWidget->setGraphic(m->getGraphic()); + coordinateWidget->setGraphic(m->GetDrawing()); #ifdef RS_CAM simulationControls->setGraphicView(m->getGraphicView()); #endif // Only graphics show blocks. (blocks don't) - if (m->getDocument()->rtti() == RS2::EntityGraphic) - blockWidget->setBlockList(m->getDocument()->getBlockList()); - else - blockWidget->setBlockList(NULL); +// if (m->getDocument()->rtti() == RS2::EntityDrawing) +// blockWidget->setBlockList(m->getDocument()->getBlockList()); +// else +// blockWidget->setBlockList(NULL); + blockWidget->setBlockList(m->getDocument()->rtti() == RS2::EntityDrawing + ? m->getDocument()->getBlockList() : NULL); // Update all inserts in this graphic (blocks might have changed): m->getDocument()->updateInserts(); @@ -1667,17 +1506,35 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) slotPenChanged(penToolBar->getPen()); // update toggle button status: - if (m->getGraphic()) + if (m->GetDrawing()) { - emit(gridChanged(m->getGraphic()->isGridOn())); - emit(printPreviewChanged(m->getGraphicView()->isPrintPreview())); +//This is odd... why do this when you can just call the function directly? It's +//IN this class after all... +// emit(gridChanged(m->GetDrawing()->isGridOn())); +// emit(printPreviewChanged(m->getGraphicView()->isPrintPreview())); + actionViewGrid->setChecked(m->GetDrawing()->isGridOn()); + actionFilePrintPreview->setChecked(m->getGraphicView()->isPrintPreview()); } } +//This works, but for some reason after this function is over, the subwindow is no +//longer activated. Need to find out why. +//OK, I can see that the workspace isn't getting this window as activated or current. +//Which means that something is definitely wrong here... + //Seems to work now. //#warning "This is failing... !!! FIX !!!" +printf("slotWindowActivated(QMdiSubWindow *): m=%08X, m->getDocument()=%08X...\n", (uint)m, (uint)(m ? m->getDocument() : 0)); +printf("slotWindowActivated(QMdiSubWindow *): activeWindow=%08X...\n", (uint)workspace->activeSubWindow()); +printf("slotWindowActivated(QMdiSubWindow *): currentWindow=%08X...\n", (uint)workspace->currentSubWindow()); +// slotWindowActivated(QMdiSubWindow * /*w*/): m=00000000, m->getDocument()=00000000... + // Disable/Enable menu and toolbar items - emit windowsChanged(m != NULL && m->getDocument() != NULL); +//This is odd... why do this when you can just call the function directly? It's +//IN this class after all... +//In this case it makes a little sense, as the signal is connected to all the actions' +//setEnabled() function calls. + emit(windowsChanged(m != NULL && m->getDocument() != NULL)); DEBUG->print("ApplicationWindow::slotWindowActivated end"); } @@ -1708,11 +1565,14 @@ void ApplicationWindow::slotWindowsMenuAboutToShow() #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!" #endif QList windows = workspace->subWindowList(); +//printf("ApplicationWindow::slotWindowsMenuAboutToShow(): workspace->activeSubWindow = %08X\n", workspace->activeSubWindow()); +//printf("ApplicationWindow::slotWindowsMenuAboutToShow(): workspace->currentSubWindow = %08X\n", workspace->currentSubWindow()); //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!" //[DONE] - for(int i=0; i Windows.at(i) = %08X\n", windows.at(i)); // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int))); //For some reason the triggered() signal created here is type bool... Dunno why... //It's signalling using the QAction signal, which is type bool (checked or not). @@ -1722,7 +1582,9 @@ void ApplicationWindow::slotWindowsMenuAboutToShow() QAction * action = new QAction(actionName, this); action->setCheckable(true); action->setData(i); - action->setChecked(workspace->activeSubWindow() == windows.at(i)); +//Neither of these work... +// action->setChecked(workspace->activeSubWindow() == windows.at(i)); + action->setChecked(workspace->currentSubWindow() == windows.at(i)); windowsMenu->addAction(action); connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *))); // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus())); @@ -1749,10 +1611,13 @@ void ApplicationWindow::slotWindowsMenuActivated(QAction * id) // QMdiSubWindow * w = workspace->subWindowList().at(id); QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt()); +printf("ApplicationWindow::slotWindowsMenuActivated: QMdiSubWindow * w = %08X\n", (uint32_t)w); if (w != NULL) - w->showMaximized(); + workspace->setActiveSubWindow(w); +// w->showMaximized(); // w->setFocus(); +printf("--> w is%s activated (activeSW=%08X)\n", (workspace->activeSubWindow() ? "" : " NOT"), (uint32_t)(workspace->activeSubWindow())); } /** @@ -1858,8 +1723,8 @@ void ApplicationWindow::slotCamExportAuto() { */ /** - * Called when something changed in the pen tool bar - * (e.g. color, width, style). + * Called when something changed in the pen tool bar (e.g. color, width, + * style). */ void ApplicationWindow::slotPenChanged(Pen pen) { @@ -1874,10 +1739,10 @@ void ApplicationWindow::slotPenChanged(Pen pen) } /** - * Creates a new MDI window with the given document or a new - * document if 'doc' is NULL. + * Creates a new MDI window with the given document or a new document if 'doc' + * is NULL. */ -MDIWindow * ApplicationWindow::slotFileNew(Document * doc) +MDIWindow * ApplicationWindow::slotFileNew(Document * doc/*= NULL*/) { DEBUG->print("ApplicationWindow::slotFileNew() begin"); @@ -1886,7 +1751,7 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) statusBar()->showMessage(tr("Creating new file...")); -#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible" +//#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible" DEBUG->print(" creating MDI window"); // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose); MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow); @@ -1895,21 +1760,17 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing())); if (w->getDocument()->rtti() == RS2::EntityBlock) -// w->setCaption(tr("Block '%1'").arg(((Block *)(w->getDocument()))->getName())); w->setWindowTitle(tr("Block '%1'").arg(((Block *)(w->getDocument()))->getName())); else -// w->setCaption(tr("unnamed document %1").arg(id)); - w->setWindowTitle(tr("unnamed document %1").arg(id)); + w->setWindowTitle(tr("Untitled Document %1").arg(id)); -// w->setIcon(qPixmapFromMimeSource("document.png")); -// w->setWindowIcon(qPixmapFromMimeSource("document.png")); w->setWindowIcon(QIcon(":/res/document.png")); +#if 0 // only graphics offer block lists, blocks don't DEBUG->print(" adding listeners"); Drawing * graphic = w->getDocument()->getGraphic(); -#if 0 if (graphic != NULL) { // Link the graphic's layer list to the pen tool bar @@ -1938,7 +1799,8 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) #if 1 //bugfix for Qt3->4 conversion DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace..."); // workspace->addWindow(w); - workspace->addSubWindow(w); + QMdiSubWindow * sw = workspace->addSubWindow(w); +printf("MDIWindow=%08X, QMdiSubWindow=%08X\n", (uint)w, (uint)sw); #endif DEBUG->print(" showing MDI window"); @@ -1958,13 +1820,25 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) // w->setFocus(); //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE")); #endif - -#warning "!!! Parameter to slotWindowActivated() is ignored !!!" - slotWindowActivated(w); +//neither of these work either +//w->activateWindow(); +//w->setFocus(); +//w->activateWindow(); +//w->raise(); +//will wok? +/*printf("FileNew: Setting active subwindow... (w=%08X)\n", (uint)w); +workspace->setActiveSubWindow(w); +printf("FileNew: Workspace active window = %08X\n", (uint)(workspace->activeSubWindow())); +//*/ + +//not anymore... #warning "!!! Parameter to slotWindowActivated() is ignored !!!" +//Hm, this should be called when the window is actually activated by the QMdiArea... +//Not sure why this isn't happening... +// slotWindowActivated(w); statusBar()->showMessage(tr("New Drawing created."), 2000); DEBUG->print("ApplicationWindow::slotFileNew() OK"); - setFocus(); +// setFocus(); return w; } @@ -2037,7 +1911,7 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t // link the block widget to the new document: blockWidget->setBlockList(w->getDocument()->getBlockList()); // link coordinate widget to graphic - coordinateWidget->setGraphic(w->getGraphic()); + coordinateWidget->setGraphic(w->GetDrawing()); #ifdef RS_CAM // link the layer widget to the new document: simulationControls->setGraphicView(w->getGraphicView()); @@ -2051,7 +1925,7 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t QApplication::restoreOverrideCursor(); QMessageBox::information(this, QMessageBox::tr("Warning"), tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok); - w->setForceClosing(true); +// w->setForceClosing(true); w->close(); return; } @@ -2283,7 +2157,7 @@ void ApplicationWindow::slotFileExport() // show options dialog: ImageOptionsDialog dlg(this); - dlg.setGraphicSize(w->getGraphic()->getSize()); + dlg.setGraphicSize(w->GetDrawing()->getSize()); if (dlg.exec()) { @@ -2319,11 +2193,11 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for return false; } - Drawing * graphic = w->getDocument()->getGraphic(); + Drawing * drawing = w->getDocument()->GetDrawing(); - if (!graphic) + if (!drawing) { - DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic"); + DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFileExport: no drawing"); return false; } @@ -2361,9 +2235,9 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for else gv.setBackground(Color(255, 255, 255)); - gv.setContainer(graphic); + gv.setContainer(drawing); gv.zoomAuto(false); - gv.drawEntity(graphic, true); + gv.drawEntity(drawing, true); #if 0 QImageIO iio; @@ -2378,14 +2252,20 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for ret = true; } #else -#warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!" +//#warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!" +// QImage image = buffer->toImage(); +// QImageWriter writer; +// writer.setFileName(name); +// writer.setFormat(format.toAscii().data()); + QImageWriter writer(name, format.toAscii().data()); + +// if (writer.write(image)) + if (writer.write(buffer->toImage())) + ret = true; #endif QApplication::restoreOverrideCursor(); - // GraphicView deletes painter -// painter->end(); - //no, it doesn't delete painter; delete buffer; @@ -2451,18 +2331,18 @@ void ApplicationWindow::slotFilePrint() return; } - Drawing * graphic = w->getDocument()->getGraphic(); + Drawing * drawing = w->getDocument()->GetDrawing(); - if (graphic == NULL) + if (drawing == NULL) { - DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic"); + DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no drawing"); return; } statusBar()->showMessage(tr("Printing...")); QPrinter * printer = new QPrinter(QPrinter::HighResolution); bool landscape = false; - printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape))); + printer->setPageSize(RS2::rsToQtPaperFormat(drawing->getPaperFormat(&landscape))); if (landscape) printer->setOrientation(QPrinter::Landscape); @@ -2502,20 +2382,17 @@ void ApplicationWindow::slotFilePrint() // double fx = (double)metr.width() / metr.widthMM() * Units::getFactorToMM(graphic->getUnit()); // double fy = (double)metr.height() / metr.heightMM() * Units::getFactorToMM(graphic->getUnit()); - double fx = (double)printer->width() / printer->widthMM() * Units::getFactorToMM(graphic->getUnit()); - double fy = (double)printer->height() / printer->heightMM() * Units::getFactorToMM(graphic->getUnit()); + double fx = (double)printer->width() / printer->widthMM() * Units::getFactorToMM(drawing->getUnit()); + double fy = (double)printer->height() / printer->heightMM() * Units::getFactorToMM(drawing->getUnit()); double f = (fx + fy) / 2; - double scale = graphic->getPaperScale(); + double scale = drawing->getPaperScale(); - gv.setOffset((int)(graphic->getPaperInsertionBase().x * f), - (int)(graphic->getPaperInsertionBase().y * f)); + gv.setOffset((int)(drawing->getPaperInsertionBase().x * f), + (int)(drawing->getPaperInsertionBase().y * f)); gv.setFactor(f * scale); - gv.setContainer(graphic); - gv.drawEntity(graphic, true); + gv.setContainer(drawing); + gv.drawEntity(drawing, true); - // GraphicView deletes painter -// painter->end(); - //no delete painter; settings.beginGroup("Print"); @@ -2548,7 +2425,7 @@ void ApplicationWindow::slotFilePrintPreview(bool on) return; } - // close print preview: + // Close print preview: if (!on) { DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off"); @@ -2559,7 +2436,7 @@ void ApplicationWindow::slotFilePrintPreview(bool on) slotFileClose(); } } - // open print preview: + // Open print preview: else { // look for an existing print preview: @@ -2580,8 +2457,6 @@ void ApplicationWindow::slotFilePrintPreview(bool on) MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow); w->setAttribute(Qt::WA_DeleteOnClose); parent->addChildWindow(w); - //connect(w, SIGNAL(signalClosing()), - // this, SLOT(slotFileClosing())); // w->setCaption(tr("Print preview for %1").arg(parent->caption())); w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle())); @@ -2592,22 +2467,14 @@ void ApplicationWindow::slotFilePrintPreview(bool on) w->getGraphicView()->setBackground(Color(255, 255, 255)); w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView())); - // only graphics offer block lists, blocks don't - DEBUG->print(" adding listeners"); - Drawing * graphic = w->getDocument()->getGraphic(); + // Only drawings offer block lists; blocks themselves don't +// DEBUG->print(" adding listeners"); + Drawing * drawing = w->getDocument()->GetDrawing(); - if (graphic) + if (drawing) { -#if 0 - // Link the layer list to the pen tool bar - graphic->addLayerListListener(penToolBar); - // Link the layer list to the layer widget - graphic->addLayerListListener(layerWidget); - // Link the block list to the block widget - graphic->addBlockListListener(blockWidget); -#endif // Center by default: - graphic->centerToPage(); + drawing->centerToPage(); } // Link the graphic view to the mouse widget: @@ -2647,25 +2514,12 @@ void ApplicationWindow::slotFileQuit() statusBar()->showMessage(tr("Exiting application...")); - if (queryExit(false)) + if (QueryExit()) qApp->exit(0); } -#if 0 -/** - * Forces termination of QCad (demo version). - */ -void ApplicationWindow::slotFileDemoQuit() -{ - statusBar()->showMessage(tr("Exiting application...")); - - queryExit(true); - qApp->exit(0); -} -#endif - /** - * Shows / hides the grid. + * Shows/hides the grid. * * @param toggle true: show, false: hide. */ @@ -2677,10 +2531,10 @@ void ApplicationWindow::slotViewGrid(bool toggle) if (m != NULL) { - Drawing * g = m->getGraphic(); + Drawing * d = m->GetDrawing(); - if (g != NULL) - g->setGridOn(toggle); + if (d != NULL) + d->setGridOn(toggle); } updateGrids(); @@ -2690,7 +2544,7 @@ void ApplicationWindow::slotViewGrid(bool toggle) } /** - * Enables / disables the draft mode. + * Enables/disables draft mode. * * @param toggle true: enable, false: disable. */ @@ -2698,14 +2552,6 @@ void ApplicationWindow::slotViewDraft(bool toggle) { DEBUG->print("ApplicationWindow::slotViewDraft()"); - /*MDIWindow* m = getMDIWindow(); - if (m!=NULL) { - Drawing* g = m->getGraphic(); - if (g!=NULL) { - g->setDraftOn(toggle); - } -}*/ - settings.beginGroup("Appearance"); settings.setValue("DraftMode", toggle); settings.endGroup(); @@ -2714,26 +2560,21 @@ void ApplicationWindow::slotViewDraft(bool toggle) } /** - * Redraws all mdi windows. + * Redraws all MDI windows. */ void ApplicationWindow::redrawAll() { - if (workspace) - { - QList windows = workspace->subWindowList(); + if (workspace == NULL) + return; - for(int i=0; i windows = workspace->subWindowList(); - if (m) - { - QG_GraphicView * gv = m->getGraphicView(); + for(int i=0; igetGraphicView(); - if (gv) - gv->redraw(); - } - } + if (gv) + gv->redraw(); } } @@ -2742,22 +2583,17 @@ void ApplicationWindow::redrawAll() */ void ApplicationWindow::updateGrids() { - if (workspace) - { - QList windows = workspace->subWindowList(); + if (workspace == NULL) + return; - for(int i=0; i windows = workspace->subWindowList(); - if (m) - { - QG_GraphicView * gv = m->getGraphicView(); + for(int i=0; igetGraphicView(); - if (gv) - gv->updateGrid(); - } - } + if (gv) + gv->updateGrid(); } } @@ -2776,102 +2612,6 @@ void ApplicationWindow::slotViewStatusBar(bool showSB) statusBar()->hide(); } -/** - * Shows / hides the layer list. - * - * @param toggle true: show, false: hide. - */ -/*void ApplicationWindow::slotViewLayerList(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewLayerList()"); - - if (toggle==false) { - layerDockWindow->hide(); - } else { - layerDockWindow->show(); - } -} -*/ - -/** - * Shows / hides the block list. - * - * @param toggle true: show, false: hide. - */ -/* -void ApplicationWindow::slotViewBlockList(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewBlockList()"); - - if (toggle==false) { - blockDockWindow->hide(); - } else { - blockDockWindow->show(); - } -} -*/ - -/** - * Shows / hides the command line. - * - * @param toggle true: show, false: hide. - */ -/* -void ApplicationWindow::slotViewCommandLine(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewCommandLine()"); - - if (toggle==false) { - commandDockWindow->hide(); - //QG_GraphicView* graphicView = getGraphicView(); - //if (graphicView!=NULL) { - //graphicView->setFocus(); - //} - setFocus(); - } else { - commandDockWindow->show(); - } -} -*/ - -/** - * Shows / hides the option toolbar. - * - * @param toggle true: show, false: hide. - */ -/* -void ApplicationWindow::slotViewOptionToolbar(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewOptionToolbar()"); - - if (toggle==false) { - optionWidget->hide(); - } else { - optionWidget->show(); - } -} -*/ - -/** - * Creates a new MDI window for editing the selected block. - */ -/* -void ApplicationWindow::slotBlocksEdit() { - DEBUG->print("ApplicationWindow::slotBlocksEdit()"); - - MDIWindow* parent = getMDIWindow(); - if (parent!=NULL) { - BlockList* blist = blockWidget->getBlockList(); - if (blist!=NULL) { - Block* blk = blist->getActiveBlock(); - if (blk!=NULL) { - MDIWindow* w = slotFileNew(blk); - // the parent needs a pointer to the block window and - // vice versa - parent->addChildWindow(w); - w->getGraphicView()->zoomAuto(); - } - } - } -} -*/ - /** * Shows the dialog for general application preferences. */ @@ -2879,7 +2619,7 @@ void ApplicationWindow::slotOptionsGeneral() { DIALOGFACTORY->requestOptionsGeneralDialog(); - // update background color of all open drawings: + // Update background color of all open drawings: settings.beginGroup("Appearance"); QColor color(settings.value("BackgroundColor", "#000000").toString()); QColor gridColor(settings.value("GridColor", "Gray").toString()); @@ -2890,7 +2630,7 @@ void ApplicationWindow::slotOptionsGeneral() QList windows = workspace->subWindowList(); - for(int i=0; iprint("ApplicationWindow::slotHelpAbout()"); +#if 0 QStringList modules; #ifdef RS_CAM @@ -2954,26 +2695,16 @@ void ApplicationWindow::slotHelpAbout() modulesString = modules.join(", "); else modulesString = tr("None"); +#endif QMessageBox box(this); box.setWindowTitle(tr("About...")); - box.setText(QString("") + // no center for main stream QCad -#ifdef QC_ABOUT_HEADER - QString("
") + - QString(QC_ABOUT_HEADER) + -#else -//FAIL "

"+ QC_APPNAME+ "

" + - "

Architektonas

" + -#endif - tr("Version: %1").arg("1.0.0") + "
" + - tr("Date: %1").arg(__DATE__) + "
" + - QString("© 2010 Underground Software,
James Hammons") + - "
" + - QString("Portions © 2001-2003 RibbonSoft") + - "
" -#ifdef QC_ABOUT_ADD_COMPANY - + QString("
") + QC_ABOUT_ADD_COMPANY -#endif + box.setText(QString("
") + + "

Architektonas

" + + tr("Version: %1").arg("1.0.0") + "
" + + tr("Date: %1").arg(__DATE__) + "
" + + QString("© 2010 Underground Software,
James Hammons") + "
" + + QString("Portions © 2001-2003 RibbonSoft") + "
" + QString("
") ); #ifndef QC_ABOUT_HEADER @@ -3395,7 +3126,7 @@ void ApplicationWindow::slotTestInsertBlock() Document * d = getDocument(); - if (d != NULL && d->rtti() == RS2::EntityGraphic) + if (d != NULL && d->rtti() == RS2::EntityDrawing) { Drawing * graphic = (Drawing *)d; @@ -3741,23 +3472,23 @@ void ApplicationWindow::slotTestInsertImage() Document * d = getDocument(); - if (d != NULL) - { - Drawing * graphic = (Drawing *)d; + if (d == NULL) + return; - if (graphic == NULL) - return; + Drawing * drawing = (Drawing *)d; - Image * image; - ImageData imageData; + if (drawing == NULL) + return; - 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); - image = new Image(graphic, imageData); + Image * image; + ImageData imageData; - image->setLayerToActive(); - image->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine)); - graphic->addEntity(image); - } + 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); + image = new Image(drawing, imageData); + + image->setLayerToActive(); + image->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine)); + drawing->addEntity(image); } /** @@ -3914,49 +3645,27 @@ void ApplicationWindow::slotTestResize1024() /** * overloaded for Message box on last window exit. */ -bool ApplicationWindow::queryExit(bool force) +bool ApplicationWindow::QueryExit(void) { DEBUG->print("ApplicationWindow::queryExit()"); - bool succ = true; - - // demo: - if (force) - { - QMessageBox::information(this, QMessageBox::tr("Warning"), - tr("This is a %1 version " - "which terminates\n" - "automatically after 10min. This software is\n" - "not intended for production use. Please buy\n" - "a full version of the application from\n%2.\n" - "You can save your work now.") -//FAIL .arg(QC_APPNAME) - .arg("Architektonas") -#ifdef QC_CUSTOM_VENDOR - .arg(QC_CUSTOM_VENDOR), -#else - .arg("RibbonSoft, http://www.ribbonsoft.com"), -#endif - QMessageBox::Ok); - } - + bool success = true; QList list = workspace->subWindowList(); -// for(QWidget * w=list.first(); w!=NULL; w=list.next()) for(int i=0; icloseMDI(force); + success = ((MDIWindow *)list[i])->CloseMDI(); - if (!succ) + if (!success) break; } - if (succ) + if (success) storeSettings(); DEBUG->print("ApplicationWindow::queryExit(): OK"); - return succ; + return success; } /** @@ -3986,7 +3695,7 @@ void ApplicationWindow::keyPressEvent(QKeyEvent * e) GraphicView * graphicView = getGraphicView(); if (graphicView) - graphicView->keyPressEvent(e); + graphicView->_keyPressEvent(e); e->accept(); } @@ -4076,13 +3785,15 @@ void ApplicationWindow::keyReleaseEvent(QKeyEvent * e) GraphicView * graphicView = getGraphicView(); if (graphicView) - graphicView->keyReleaseEvent(e); + graphicView->_keyReleaseEvent(e); e->accept(); } break; } +// THIS LOOKS LIKE A BUG TO ME... +#warning "!!! keyPressEvent called in keyReleaseEvent !!!" // Q3MainWindow::keyPressEvent(e); QMainWindow::keyPressEvent(e); } @@ -4104,15 +3815,18 @@ QMdiArea * ApplicationWindow::getWorkspace() } /** - * @return Pointer to the currently active MDI Window or NULL if no - * MDI Window is active. + * @return Pointer to the currently active MDI Window or NULL if no MDI Window + * is active. */ MDIWindow * ApplicationWindow::getMDIWindow() { DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace); +// Here is the problem: Window isn't active... if (workspace) { +printf("ApplicationWindow::getMDIWindow: activeSubWindow =%08X\n", (uint)workspace->activeSubWindow()); +printf("ApplicationWindow::getMDIWindow: currentSubWindow=%08X\n", (uint)workspace->currentSubWindow()); DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow()); return (MDIWindow *)workspace->activeSubWindow(); } @@ -4159,6 +3873,7 @@ MDIWindow * ApplicationWindow::getMDIWindow() getDocument()->setFilename(fileName); } +#if 0 /** * Implementation from QG_MainWindowInterface. * @@ -4176,6 +3891,7 @@ MDIWindow * ApplicationWindow::getMDIWindow() { return actionHandler; } +#endif /** * Implementation from QG_MainWindowInterface.