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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/10/2010 Created this file. :-)
13 // JLH 06/22/2010 Refactored file to remove .ui dependency. This also results
14 // in a much smaller, easier to manage file. ;-)
17 #include "cadtoolbarmain.h"
19 #include "qg_actionhandler.h"
20 #include "cadtoolbar.h"
22 CadToolBarMain::CadToolBarMain(CadToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23 QWidget((QWidget *)parent, flags)
25 QG_ActionHandler * actionHandler = parent->getActionHandler();
27 gridLayout = new QGridLayout(this);
28 gridLayout->setSpacing(0);
29 gridLayout->setContentsMargins(0, 0, 0, 0);
31 connect(CreateToolButton(0, 0, ":/res/qg_menupoint"), SIGNAL(clicked()),
32 actionHandler, SLOT(slotDrawPoint()));
33 connect(CreateToolButton(0, 1, ":/res/qg_menuline"), SIGNAL(clicked()),
34 parent, SLOT(showToolBarLines()));
35 connect(CreateToolButton(1, 0, ":/res/qg_menuarc"), SIGNAL(clicked()),
36 parent, SLOT(showToolBarArcs()));
37 connect(CreateToolButton(1, 1, ":/res/qg_menucircle"), SIGNAL(clicked()),
38 parent, SLOT(showToolBarCircles()));
39 connect(CreateToolButton(2, 0, ":/res/qg_menuellipse"), SIGNAL(clicked()),
40 parent, SLOT(showToolBarEllipses()));
41 connect(CreateToolButton(2, 1, ":/res/qg_menuspline"), SIGNAL(clicked()),
42 actionHandler, SLOT(slotDrawSpline()));
43 connect(CreateToolButton(3, 0, ":/res/qg_menupolyline"), SIGNAL(clicked()),
44 parent, SLOT(showToolBarPolylines()));
46 connect(CreateToolButton(5, 0, ":/res/qg_menutext"), SIGNAL(clicked()),
47 actionHandler, SLOT(slotDrawText()));
48 connect(CreateToolButton(5, 1, ":/res/qg_menudim"), SIGNAL(clicked()),
49 parent, SLOT(showToolBarDim()));
50 connect(CreateToolButton(6, 0, ":/res/qg_menuhatch"), SIGNAL(clicked()),
51 actionHandler, SLOT(slotDrawHatch()));
52 connect(CreateToolButton(6, 1, ":/res/qg_menuimage"), SIGNAL(clicked()),
53 actionHandler, SLOT(slotDrawImage()));
55 connect(CreateToolButton(8, 0, ":/res/qg_menuedit"), SIGNAL(clicked()),
56 parent, SLOT(showToolBarModify()));
57 connect(CreateToolButton(8, 1, ":/res/qg_menumeasure"), SIGNAL(clicked()),
58 parent, SLOT(showToolBarInfo()));
60 connect(CreateToolButton(10, 0, ":/res/qg_menublock"), SIGNAL(clicked()),
61 actionHandler, SLOT(slotBlocksCreate()));
62 connect(CreateToolButton(10, 1, ":/res/qg_menuselect"), SIGNAL(clicked()),
63 parent, SLOT(showToolBarSelect()));
66 CadToolBarMain::~CadToolBarMain()
70 QToolButton * CadToolBarMain::CreateToolButton(int row, int col, QString iconName)
72 QToolButton * button = new QToolButton(this);
73 button->setIcon(QIcon(iconName));
74 button->setIconSize(QSize(18, 18));
75 gridLayout->addWidget(button, row, col, 1, 1);