Salome HOME
Temporary comment (somehow inform the user about the scale of the view: line lenght...
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetToolbox.cpp
1 /*
2  * ModuleBase_WidgetToolbox.cpp
3  *
4  *  Created on: Feb 27, 2015
5  *      Author: sbh
6  */
7
8 #include <ModuleBase_WidgetToolbox.h>
9 #include <ModuleBase_PageBase.h>
10 #include <ModuleBase_ModelWidget.h>
11 #include <ModuleBase_Tools.h>
12 #include <ModuleBase_ToolBox.h>
13
14 #include <ModelAPI_AttributeString.h>
15
16 #include <QWidget>
17 #include <QList>
18 #include <QVBoxLayout>
19 #include <QIcon>
20
21 ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData)
22 : ModuleBase_PagedContainer(theParent, theData)
23 {
24   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
25   ModuleBase_Tools::zeroMargins(aMainLayout);
26   myToolBox = new ModuleBase_ToolBox(this);
27   // Dark-grey rounded tabs with button-like border #and bold font
28   // TODO: apply style to custom widget
29   QString css = "QToolBox::tab{background-color:#c8c8c8;"
30                               "border-radius:5px;"
31                               "border:1px inset;"
32                               //"font-weight:700;"
33                               "border-color:#fff #505050 #505050 #fff;}";
34   myToolBox->setStyleSheet(css);
35   // default vertical size policy is preferred
36   aMainLayout->addWidget(myToolBox);
37
38   connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
39 }
40
41 ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
42 {
43 }
44
45 int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
46                                       const QString& theName,
47                                       const QString& theCaseId,
48                                       const QPixmap& theIcon )
49 {
50   ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
51   QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
52   aFrame->setFrameStyle(QFrame::Box | QFrame::Raised);
53   myToolBox->addItem(aFrame, theName, theIcon );
54   return myToolBox->count();
55 }
56
57 int ModuleBase_WidgetToolbox::currentPageIndex() const
58 {
59   return myToolBox->currentIndex();
60 }
61
62 void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex)
63 {
64   bool isSignalsBlocked = myToolBox->blockSignals(true);
65   myToolBox->setCurrentIndex(theIndex);
66   myToolBox->blockSignals(isSignalsBlocked);
67 }
68
69