]> Shamusworld >> Repos - architektonas/blobdiff - src/forms/cadtoolbarmain.cpp
In the middle of major refactoring...
[architektonas] / src / forms / cadtoolbarmain.cpp
index b2111e9a1f731fb02979ef6ad09925b9004f0616..afddfb1bf954750e272107b1c82dedf54766ffbc 100644 (file)
@@ -1,5 +1,6 @@
 // cadtoolbarmain.cpp
 //
+// Part of the Architektonas Project
 // Originally part of QCad Community Edition by Andrew Mustun
 // Extensively rewritten and refactored by James L. Hammons
 // (C) 2010 Underground Software
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/10/2010  Created this file. :-)
+// JLH  06/22/2010  Refactored file to remove .ui dependency. This also results
+//                  in a much smaller, easier to manage file. ;-)
 //
 
 #include "cadtoolbarmain.h"
 
-#include "cadtoolbar.h"
 #include "qg_actionhandler.h"
+#include "cadtoolbar.h"
 
-CadToolBarMain::CadToolBarMain(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
-       QWidget(parent, flags)
+CadToolBarMain::CadToolBarMain(CadToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
+       QWidget((QWidget *)parent, flags)
 {
-       ui.setupUi(this);
+       QG_ActionHandler * actionHandler = parent->getActionHandler();
+
+       gridLayout = new QGridLayout(this);
+       gridLayout->setSpacing(0);
+       gridLayout->setContentsMargins(0, 0, 0, 0);
+
+       connect(CreateToolButton(0, 0, ":/res/qg_menupoint"), SIGNAL(clicked()),
+               actionHandler, SLOT(slotDrawPoint()));
+       connect(CreateToolButton(0, 1, ":/res/qg_menuline"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarLines()));
+       connect(CreateToolButton(1, 0, ":/res/qg_menuarc"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarArcs()));
+       connect(CreateToolButton(1, 1, ":/res/qg_menucircle"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarCircles()));
+       connect(CreateToolButton(2, 0, ":/res/qg_menuellipse"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarEllipses()));
+       connect(CreateToolButton(2, 1, ":/res/qg_menuspline"), SIGNAL(clicked()),
+               actionHandler, SLOT(slotDrawSpline()));
+       connect(CreateToolButton(3, 0, ":/res/qg_menupolyline"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarPolylines()));
+
+       connect(CreateToolButton(5, 0, ":/res/qg_menutext"), SIGNAL(clicked()),
+               actionHandler, SLOT(slotDrawText()));
+       connect(CreateToolButton(5, 1, ":/res/qg_menudim"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarDim()));
+       connect(CreateToolButton(6, 0, ":/res/qg_menuhatch"), SIGNAL(clicked()),
+               actionHandler, SLOT(slotDrawHatch()));
+       connect(CreateToolButton(6, 1, ":/res/qg_menuimage"), SIGNAL(clicked()),
+               actionHandler, SLOT(slotDrawImage()));
 
-// Ain't hidin' dis no mo'...
-//#ifndef RS_PROF
-//     ui.bMenuPolyline->hide();
-//#endif
+       connect(CreateToolButton(8, 0, ":/res/qg_menuedit"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarModify()));
+       connect(CreateToolButton(8, 1, ":/res/qg_menumeasure"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarInfo()));
+
+       connect(CreateToolButton(10, 0, ":/res/qg_menublock"), SIGNAL(clicked()),
+               actionHandler, SLOT(slotBlocksCreate()));
+       connect(CreateToolButton(10, 1, ":/res/qg_menuselect"), SIGNAL(clicked()),
+               parent, SLOT(showToolBarSelect()));
 }
 
 CadToolBarMain::~CadToolBarMain()
 {
 }
 
-void CadToolBarMain::setCadToolBar(CadToolBar * tb)
+QToolButton * CadToolBarMain::CreateToolButton(int row, int col, QString iconName)
 {
-       QG_ActionHandler * ah = NULL;
-
-       if (tb != NULL)
-               ah = tb->getActionHandler();
-       else
-               RS_DEBUG->print(RS_Debug::D_ERROR, "QG_CadToolBarMain::setCadToolBar(): No valid toolbar set.");
-
-       if (ah != NULL)
-       {
-               connect(ui.bMenuPoint, SIGNAL(clicked()), ah, SLOT(slotDrawPoint()));
-               connect(ui.bMenuLine, SIGNAL(clicked()), tb, SLOT(showToolBarLines()));
-               connect(ui.bMenuArc, SIGNAL(clicked()), tb, SLOT(showToolBarArcs()));
-               connect(ui.bMenuCircle, SIGNAL(clicked()), tb, SLOT(showToolBarCircles()));
-               connect(ui.bMenuEllipse, SIGNAL(clicked()), tb, SLOT(showToolBarEllipses()));
-               connect(ui.bMenuSpline, SIGNAL(clicked()), ah, SLOT(slotDrawSpline()));
-               connect(ui.bMenuPolyline, SIGNAL(clicked()), tb, SLOT(showToolBarPolylines()));
-
-               connect(ui.bMenuText, SIGNAL(clicked()), ah, SLOT(slotDrawText()));
-               connect(ui.bMenuDim, SIGNAL(clicked()), tb, SLOT(showToolBarDim()));
-               connect(ui.bMenuHatch, SIGNAL(clicked()), ah, SLOT(slotDrawHatch()));
-               connect(ui.bMenuImage, SIGNAL(clicked()), ah, SLOT(slotDrawImage()));
-
-               connect(ui.bMenuModify, SIGNAL(clicked()), tb, SLOT(showToolBarModify()));
-               connect(ui.bMenuInfo, SIGNAL(clicked()), tb, SLOT(showToolBarInfo()));
+       QToolButton * button = new QToolButton(this);
+       button->setIcon(QIcon(iconName));
+       button->setIconSize(QSize(18, 18));
+       gridLayout->addWidget(button, row, col, 1, 1);
 
-               connect(ui.bMenuBlock, SIGNAL(clicked()), ah, SLOT(slotBlocksCreate()));
-               connect(ui.bMenuSelect, SIGNAL(clicked()), tb, SLOT(showToolBarSelect()));
-       }
-       else
-       {
-               RS_DEBUG->print(RS_Debug::D_ERROR, "QG_CadToolBarMain::setCadToolBar(): No valid action handler set.");
-       }
+       return button;
 }