Salome HOME
202be90fc640838f981c1e2c15e34171f4a927b7
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
1 /*
2  * XGUI_PropertyPanel.cpp
3  *
4  *  Created on: Apr 29, 2014
5  *      Author: sbh
6  */
7
8 #include <XGUI_Constants.h>
9 #include <XGUI_PropertyPanel.h>
10
11 #include <ModuleBase_PropPanelOperation.h>
12
13 #include <QWidget>
14 #include <QVBoxLayout>
15 #include <QFrame>
16 #include <QPushButton>
17 #include <QIcon>
18 #include <QVBoxLayout>
19
20 #ifdef _DEBUG
21 #include <iostream>
22 #endif
23
24 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
25 {
26   this->setWindowTitle(tr("Property Panel"));
27   QAction* aViewAct = this->toggleViewAction();
28   this->setObjectName(XGUI::PROP_PANEL);
29
30   QWidget* aContent = new QWidget(this);
31   QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
32   aMainLay->setContentsMargins(3, 3, 3, 3);
33   this->setWidget(aContent);
34
35   QFrame* aFrm = new QFrame(aContent);
36   aFrm->setFrameStyle(QFrame::Sunken);
37   aFrm->setFrameShape(QFrame::Panel);
38   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
39   aBtnLay->setContentsMargins(0, 0, 0, 0);
40   aMainLay->addWidget(aFrm);
41
42   QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
43   aBtn->setFlat(true);
44   aBtnLay->addWidget(aBtn);
45   aBtnLay->addStretch(1);
46   aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
47   aBtn->setObjectName(XGUI::PROP_PANEL_OK);
48   aBtn->setFlat(true);
49   aBtnLay->addWidget(aBtn);
50   aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
51   aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
52   aBtn->setFlat(true);
53   aBtnLay->addWidget(aBtn);
54
55   myCustomWidget = new QWidget(aContent);
56   aMainLay->addWidget(myCustomWidget);
57   aMainLay->addStretch(1);
58 }
59
60 XGUI_PropertyPanel::~XGUI_PropertyPanel()
61 {
62 }
63
64 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_IModelWidget*>& theWidgets)
65 {
66   myWidgets = theWidgets;
67 }
68
69 QWidget* XGUI_PropertyPanel::contentWidget()
70 {
71   return myCustomWidget;
72 }
73
74 void XGUI_PropertyPanel::updateContentWidget()
75 {
76   foreach(ModuleBase_IModelWidget* eachWidget, myWidgets) {
77     eachWidget->restoreValue();
78   }
79 }