]> Shamusworld >> Repos - architektonas/blob - src/forms/cadtoolbarmain.cpp
afddfb1bf954750e272107b1c82dedf54766ffbc
[architektonas] / src / forms / cadtoolbarmain.cpp
1 // cadtoolbarmain.cpp
2 //
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
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
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. ;-)
15 //
16
17 #include "cadtoolbarmain.h"
18
19 #include "qg_actionhandler.h"
20 #include "cadtoolbar.h"
21
22 CadToolBarMain::CadToolBarMain(CadToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23         QWidget((QWidget *)parent, flags)
24 {
25         QG_ActionHandler * actionHandler = parent->getActionHandler();
26
27         gridLayout = new QGridLayout(this);
28         gridLayout->setSpacing(0);
29         gridLayout->setContentsMargins(0, 0, 0, 0);
30
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()));
45
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()));
54
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()));
59
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()));
64 }
65
66 CadToolBarMain::~CadToolBarMain()
67 {
68 }
69
70 QToolButton * CadToolBarMain::CreateToolButton(int row, int col, QString iconName)
71 {
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);
76
77         return button;
78 }