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/10/2010 Created this file. :-)
15 // JLH 06/22/2010 Refactored file to remove .ui dependency. This also results
16 // in a much smaller, easier to manage file. ;-)
19 #include "cadtoolbarmain.h"
21 #include "actionhandler.h"
22 #include "cadtoolbar.h"
24 CadToolBarMain::CadToolBarMain(CadToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
25 QWidget((QWidget *)parent, flags)
27 ActionHandler * actionHandler = parent->getActionHandler();
29 gridLayout = new QGridLayout(this);
30 gridLayout->setSpacing(0);
31 gridLayout->setContentsMargins(0, 0, 0, 0);
33 connect(CreateToolButton(0, 0, ":/res/qg_menupoint"), SIGNAL(clicked()),
34 actionHandler, SLOT(slotDrawPoint()));
35 connect(CreateToolButton(0, 1, ":/res/qg_menuline"), SIGNAL(clicked()),
36 parent, SLOT(showToolBarLines()));
37 connect(CreateToolButton(1, 0, ":/res/qg_menuarc"), SIGNAL(clicked()),
38 parent, SLOT(showToolBarArcs()));
39 connect(CreateToolButton(1, 1, ":/res/qg_menucircle"), SIGNAL(clicked()),
40 parent, SLOT(showToolBarCircles()));
41 connect(CreateToolButton(2, 0, ":/res/qg_menuellipse"), SIGNAL(clicked()),
42 parent, SLOT(showToolBarEllipses()));
43 connect(CreateToolButton(2, 1, ":/res/qg_menuspline"), SIGNAL(clicked()),
44 actionHandler, SLOT(slotDrawSpline()));
45 connect(CreateToolButton(3, 0, ":/res/qg_menupolyline"), SIGNAL(clicked()),
46 parent, SLOT(showToolBarPolylines()));
48 connect(CreateToolButton(5, 0, ":/res/qg_menutext"), SIGNAL(clicked()),
49 actionHandler, SLOT(slotDrawText()));
50 connect(CreateToolButton(5, 1, ":/res/qg_menudim"), SIGNAL(clicked()),
51 parent, SLOT(showToolBarDim()));
52 connect(CreateToolButton(6, 0, ":/res/qg_menuhatch"), SIGNAL(clicked()),
53 actionHandler, SLOT(slotDrawHatch()));
54 connect(CreateToolButton(6, 1, ":/res/qg_menuimage"), SIGNAL(clicked()),
55 actionHandler, SLOT(slotDrawImage()));
57 connect(CreateToolButton(8, 0, ":/res/qg_menuedit"), SIGNAL(clicked()),
58 parent, SLOT(showToolBarModify()));
59 connect(CreateToolButton(8, 1, ":/res/qg_menumeasure"), SIGNAL(clicked()),
60 parent, SLOT(showToolBarInfo()));
62 connect(CreateToolButton(10, 0, ":/res/qg_menublock"), SIGNAL(clicked()),
63 actionHandler, SLOT(slotBlocksCreate()));
64 connect(CreateToolButton(10, 1, ":/res/qg_menuselect"), SIGNAL(clicked()),
65 parent, SLOT(showToolBarSelect()));
68 CadToolBarMain::~CadToolBarMain()
72 QToolButton * CadToolBarMain::CreateToolButton(int row, int col, QString iconName)
74 QToolButton * button = new QToolButton(this);
75 button->setIcon(QIcon(iconName));
76 button->setIconSize(QSize(18, 18));
77 gridLayout->addWidget(button, row, col, 1, 1);