]> Shamusworld >> Repos - architektonas/blobdiff - src/forms/cadtoolbar.cpp
In the middle of major refactoring...
[architektonas] / src / forms / cadtoolbar.cpp
index 07a7aa3084e3653a49f7d2f57d50748a44881617..d988c7ca3895c764d8e72fb2d2c3bb8ab778c931 100644 (file)
@@ -1,5 +1,6 @@
 // cadtoolbar.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
@@ -34,7 +35,19 @@ CadToolBar::CadToolBar(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
        tbEllipses(NULL), tbArcs(NULL), tbModify(NULL), tbCircles(NULL), tbSnap(NULL),
        tbSelect(NULL), tbPolylines(NULL)
 {
-       ui.setupUi(this);
+//hmm.
+#if 1
+       resize(86, 336);
+//     QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
+//     policy.setHorizontalStretch(0);
+//     policy.setVerticalStretch(0);
+//     policy.setHeightForWidth(sizePolicy().hasHeightForWidth());
+//     setSizePolicy(policy);
+       setMinimumSize(QSize(56, 336));
+#endif
+//hm. here maybe? Yesh!
+       if (parent)
+               ((QToolBar *)parent)->addWidget(this);
 }
 
 CadToolBar::~CadToolBar()
@@ -62,7 +75,7 @@ void CadToolBar::back()
  */
 void CadToolBar::forceNext()
 {
-       if (currentTb != NULL && currentTb == tbSelect)
+       if (currentTb && currentTb == tbSelect)
                tbSelect->runNextAction();
 }
 
@@ -89,59 +102,33 @@ void CadToolBar::createSubToolBars(QG_ActionHandler * ah)
 {
        actionHandler = ah;
        tbMain = new CadToolBarMain(this);
-       tbMain->setCadToolBar(this);
+       currentTb = tbMain;
 
        tbPoints = new CadToolBarPoints(this);
-       tbPoints->setCadToolBar(this);
-       tbPoints->hide();
-
        tbLines = new CadToolBarLines(this);
-       tbLines->setCadToolBar(this);
-       tbLines->hide();
-
        tbArcs = new CadToolBarArcs(this);
-       tbArcs->setCadToolBar(this);
-       tbArcs->hide();
-
        tbCircles = new CadToolBarCircles(this);
-       tbCircles->setCadToolBar(this);
-       tbCircles->hide();
-
        tbEllipses = new CadToolBarEllipses(this);
-       tbEllipses->setCadToolBar(this);
-       tbEllipses->hide();
-
        tbSplines = new CadToolBarSplines(this);
-       tbSplines->setCadToolBar(this);
-       tbSplines->hide();
-
-//#ifdef RS_PROF
        tbPolylines = new CadToolBarPolylines(this);
-       tbPolylines->setCadToolBar(this);
-       tbPolylines->hide();
-//#endif
-
        tbDim = new CadToolBarDim(this);
-       tbDim->setCadToolBar(this);
-       tbDim->hide();
-
        tbInfo = new CadToolBarInfo(this);
-       tbInfo->setCadToolBar(this);
-       tbInfo->hide();
-
        tbModify = new CadToolBarModify(this);
-       tbModify->setCadToolBar(this);
-       tbModify->hide();
-
        tbSnap = new CadToolBarSnap(this);
-       tbSnap->setCadToolBar(this);
-       tbSnap->hide();
-
        tbSelect = new CadToolBarSelect(this);
-       tbSelect->setCadToolBar(this);
-       tbSelect->hide();
 
-       //showToolBarMain();
+       tbPoints->hide();
+       tbLines->hide();
+       tbArcs->hide();
+       tbCircles->hide();
+       tbEllipses->hide();
+       tbSplines->hide();
+       tbPolylines->hide();
+       tbDim->hide();
+       tbInfo->hide();
+       tbModify->hide();
+       tbSnap->hide();
+       tbSelect->hide();
 }
 
 void CadToolBar::showToolBar(int id)
@@ -169,11 +156,9 @@ void CadToolBar::showToolBar(int id)
        case RS2::ToolBarSplines:
                newTb = tbSplines;
                break;
-//#ifdef RS_PROF
        case RS2::ToolBarPolylines:
                newTb = tbPolylines;
                break;
-//#endif
        case RS2::ToolBarCircles:
                newTb = tbCircles;
                break;
@@ -197,12 +182,12 @@ void CadToolBar::showToolBar(int id)
        if (currentTb == newTb)
                return;
 
-       if (currentTb != NULL)
+       if (currentTb)
                currentTb->hide();
 
        currentTb = newTb;
 
-       if (currentTb != NULL)
+       if (currentTb)
                currentTb->show();
 }
 
@@ -238,9 +223,7 @@ void CadToolBar::showToolBarSplines()
 
 void CadToolBar::showToolBarPolylines()
 {
-//#ifdef RS_PROF
        showToolBar(RS2::ToolBarPolylines);
-//#endif
 }
 
 void CadToolBar::showToolBarCircles()
@@ -273,9 +256,30 @@ void CadToolBar::showToolBarSelect()
        showToolBarSelect(NULL, -1);
 }
 
-void CadToolBar::showToolBarSelect(RS_ActionInterface * selectAction, int nextAction)
+void CadToolBar::showToolBarSelect(ActionInterface * selectAction, int nextAction)
 {
        tbSelect->setNextAction(nextAction);
        tbSelect->setSelectAction(selectAction);
        showToolBar(RS2::ToolBarSelect);
 }
+
+QToolButton * CadToolBar::CreateBackButton(QWidget * widget)
+{
+       QAction * actionBack = new QAction(QIcon(":/res/qg_back"), tr("Back"), widget);
+       QToolButton * button = new QToolButton(widget);
+       button->setDefaultAction(actionBack);
+       QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+       button->setSizePolicy(policy);
+       connect(button, SIGNAL(triggered(QAction *)), this, SLOT(back()));
+
+       return button;
+}
+
+QToolButton * CadToolBar::CreateToolButton(QAction * action)
+{
+       QToolButton * button = new QToolButton();
+       button->setDefaultAction(action);
+       button->setIconSize(QSize(18, 18));
+
+       return button;
+}