]> Shamusworld >> Repos - architektonas/blob - forms/cadtoolbararcs.cpp
Updated the TODO.
[architektonas] / forms / cadtoolbararcs.cpp
1 // cadtoolbararcs.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 //
14
15 #include "cadtoolbararcs.h"
16
17 #if 0
18 #include "cadtoolbar.h"
19 #include "qg_actionhandler.h"
20 #include "rs_debug.h"
21
22 CadToolBarArcs::CadToolBarArcs(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23         QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
24 {
25         ui.setupUi(this);
26 }
27
28 CadToolBarArcs::~CadToolBarArcs()
29 {
30 }
31
32 /*void QG_CadToolBarArcs::mousePressEvent(QMouseEvent* e) {
33         if (e->button()==RightButton && cadToolBar!=NULL) {
34                 cadToolBar->back();
35                 e->accept();
36         }
37 }*/
38
39 void CadToolBarArcs::contextMenuEvent(QContextMenuEvent * e)
40 {
41         e->accept();
42 }
43
44 void CadToolBarArcs::setCadToolBar(CadToolBar * tb)
45 {
46         cadToolBar = tb;
47
48         if (tb != NULL)
49                 actionHandler = tb->getActionHandler();
50         else
51                 RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarArcs::setCadToolBar(): No valid toolbar set.");
52 }
53
54 void CadToolBarArcs::drawArc()
55 {
56         if (cadToolBar != NULL && actionHandler != NULL)
57                 actionHandler->slotDrawArc();
58 }
59
60 void CadToolBarArcs::drawArc3P()
61 {
62         if (cadToolBar != NULL && actionHandler != NULL)
63                 actionHandler->slotDrawArc3P();
64 }
65
66 void CadToolBarArcs::drawArcParallel()
67 {
68         if (cadToolBar != NULL && actionHandler != NULL)
69                 actionHandler->slotDrawArcParallel();
70 }
71
72 void CadToolBarArcs::drawArcTangential()
73 {
74         if (cadToolBar != NULL && actionHandler != NULL)
75                 actionHandler->slotDrawArcTangential();
76 }
77
78 void CadToolBarArcs::back()
79 {
80         if (cadToolBar != NULL)
81                 cadToolBar->back();
82 }
83 #else
84 #include "cadtoolbar.h"
85 #include "createqtactions.h"
86
87 CadToolBarArcs::CadToolBarArcs(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/):
88         QWidget((QWidget *)parent, flags), cadToolBar(parent)
89 {
90         QGridLayout * gridLayout = new QGridLayout(this);
91         gridLayout->setSpacing(0);
92         gridLayout->setContentsMargins(0, 0, 0, 0);
93
94         QAction * actionBack = new QAction(QIcon(":/res/qg_back"), tr("Back"), this);
95         QToolButton * button = new QToolButton(this);
96         button->setDefaultAction(actionBack);
97         QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
98         button->setSizePolicy(policy);
99         gridLayout->addWidget(button, 0, 0, 1, 2);
100         connect(button, SIGNAL(triggered(QAction *)), this, SLOT(back()));
101
102         gridLayout->addWidget(CreateToolButton(actionDrawArc), 1, 0, 1, 1);
103         gridLayout->addWidget(CreateToolButton(actionDrawArc3P), 1, 1, 1, 1);
104         gridLayout->addWidget(CreateToolButton(actionDrawArcParallel), 2, 0, 1, 1);
105         gridLayout->addWidget(CreateToolButton(actionDrawArcTangential), 2, 1, 1, 1);
106 }
107
108 CadToolBarArcs::~CadToolBarArcs()
109 {
110 }
111
112 void CadToolBarArcs::back()
113 {
114         cadToolBar->back();
115 }
116
117 QToolButton * CadToolBarArcs::CreateToolButton(QAction * action)
118 {
119         QToolButton * button = new QToolButton(this);
120         button->setDefaultAction(action);
121         button->setIconSize(QSize(18, 18));
122
123         return button;
124 }
125 #endif