From b25922145a97fccf8d2613d0ef52a283d3ce0987 Mon Sep 17 00:00:00 2001 From: sbh Date: Thu, 26 Feb 2015 21:21:10 +0300 Subject: [PATCH] Property panel widgets redesign --- src/Config/Config_FeatureReader.cpp | 1 + src/ConstructionPlugin/axis_widget.xml | 43 +++++++---- src/ModuleBase/ModuleBase_ModelWidget.cpp | 9 ++- src/ModuleBase/ModuleBase_ModelWidget.h | 8 +- src/ModuleBase/ModuleBase_Tools.cpp | 2 +- src/ModuleBase/ModuleBase_WidgetBoolValue.cpp | 5 -- src/ModuleBase/ModuleBase_WidgetBoolValue.h | 2 - src/ModuleBase/ModuleBase_WidgetChoice.cpp | 7 +- src/ModuleBase/ModuleBase_WidgetChoice.h | 10 --- .../ModuleBase_WidgetDoubleValue.cpp | 14 ++-- src/ModuleBase/ModuleBase_WidgetDoubleValue.h | 10 --- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 74 +++++++++++++------ src/ModuleBase/ModuleBase_WidgetFactory.h | 3 + .../ModuleBase_WidgetFileSelector.cpp | 20 ++--- .../ModuleBase_WidgetFileSelector.h | 5 -- src/ModuleBase/ModuleBase_WidgetLabel.cpp | 15 ++-- src/ModuleBase/ModuleBase_WidgetLabel.h | 4 +- src/ModuleBase/ModuleBase_WidgetLineEdit.cpp | 18 ++--- src/ModuleBase/ModuleBase_WidgetLineEdit.h | 5 -- .../ModuleBase_WidgetMultiSelector.cpp | 21 ++---- .../ModuleBase_WidgetMultiSelector.h | 7 -- .../ModuleBase_WidgetShapeSelector.cpp | 15 ++-- .../ModuleBase_WidgetShapeSelector.h | 11 --- src/PartSet/PartSet_Module.cpp | 58 ++++++--------- src/PartSet/PartSet_WidgetPoint2d.cpp | 9 +-- src/PartSet/PartSet_WidgetPoint2d.h | 4 - src/PartSet/PartSet_WidgetSketchLabel.cpp | 16 ++-- src/PartSet/PartSet_WidgetSketchLabel.h | 2 - src/XGUI/XGUI_ActionsMgr.cpp | 3 - src/XGUI/XGUI_ObjectsBrowser.cpp | 6 +- src/XGUI/XGUI_PropertyPanel.cpp | 52 ++++--------- src/XGUI/XGUI_PropertyPanel.h | 4 +- 32 files changed, 194 insertions(+), 269 deletions(-) diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 839eca241..7f51d34ab 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -69,6 +69,7 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) aMessage->setAttributeId(anAttributeID); aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true)); aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false)); + //aMessage->setCaseId Events_Loop::loop()->send(aMessage); } } diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index a3424e3f1..004274569 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -1,19 +1,32 @@ - - - - - - - + + + + + + + + + + + + + + + + diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 6351c4f78..6dfddcc39 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -17,15 +17,16 @@ #include #include -#include #include #include #include -ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData, +ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, + const Config_WidgetAPI* theData, const std::string& theParentId) - : QObject(theParent), - myParentId(theParentId) + : QWidget(theParent), + myParentId(theParentId), + myIsEditing(false) { myDefaultValue = theData->getProperty(ATTR_DEFAULT); myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index a6830788e..3b396c9a5 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -12,7 +12,7 @@ #include -#include +#include #include @@ -28,7 +28,7 @@ class QKeyEvent; * Every widget are able to save/restore data from the model and/or to contain other widgets. * */ -class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QObject +class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QWidget { Q_OBJECT public: @@ -89,10 +89,6 @@ Q_OBJECT /// The methiod called when widget is deactivated virtual void deactivate() {} - /// Returns the internal parent wiget control, that can be shown anywhere - /// \returns the widget - virtual QWidget* getControl() const = 0; - /// Returns list of widget controls /// \return a control list virtual QList getControls() const = 0; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 38357449c..06e8fb08d 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -28,7 +28,7 @@ void adjustMargins(QLayout* theLayout) { if(!theLayout) return; - theLayout->setContentsMargins(2, 5, 5, 2); + theLayout->setContentsMargins(2, 5, 2, 5); theLayout->setSpacing(4); } diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index 87e26a78f..122f4b41c 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -39,11 +39,6 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue() { } -QWidget* ModuleBase_WidgetBoolValue::getControl() const -{ - return myCheckBox; -} - bool ModuleBase_WidgetBoolValue::storeValue() const { DataPtr aData = myFeature->data(); diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.h b/src/ModuleBase/ModuleBase_WidgetBoolValue.h index 518d9a163..4dd9b709a 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.h +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.h @@ -35,8 +35,6 @@ Q_OBJECT virtual QList getControls() const; - QWidget* getControl() const; - protected: /// Saves the internal parameters to the given feature /// \return True in success diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index 7156a0f45..a05a2fb72 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -21,18 +21,17 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId) { - myContainer = new QWidget(theParent); - QHBoxLayout* aLayout = new QHBoxLayout(myContainer); + QHBoxLayout* aLayout = new QHBoxLayout(this); ModuleBase_Tools::adjustMargins(aLayout); QString aLabelText = QString::fromStdString(theData->widgetLabel()); QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); - myLabel = new QLabel(aLabelText, myContainer); + myLabel = new QLabel(aLabelText, this); if (!aLabelIcon.isEmpty()) myLabel->setPixmap(QPixmap(aLabelIcon)); aLayout->addWidget(myLabel); - myCombo = new QComboBox(myContainer); + myCombo = new QComboBox(this); aLayout->addWidget(myCombo, 1); std::string aTypes = theData->getProperty("string_list"); diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.h b/src/ModuleBase/ModuleBase_WidgetChoice.h index 18fcb55bd..f5b9ce546 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.h +++ b/src/ModuleBase/ModuleBase_WidgetChoice.h @@ -43,13 +43,6 @@ Q_OBJECT virtual bool focusTo(); - /// Returns the internal parent wiget control, that can be shown anywhere - /// \returns the widget - QWidget* getControl() const - { - return myContainer; - } - /// Returns list of widget controls /// \return a controls list virtual QList getControls() const; @@ -64,9 +57,6 @@ private slots: void onCurrentIndexChanged(int theIndex); private: - /// Container widget - QWidget* myContainer; - /// The label QLabel* myLabel; diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 2b5437e46..e314234a2 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -37,18 +37,16 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId) { - myContainer = new QWidget(theParent); - QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); + QFormLayout* aControlLay = new QFormLayout(this); ModuleBase_Tools::adjustMargins(aControlLay); QString aLabelText = QString::fromStdString(theData->widgetLabel()); QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); - myLabel = new QLabel(aLabelText, myContainer); + myLabel = new QLabel(aLabelText, this); if (!aLabelIcon.isEmpty()) myLabel->setPixmap(QPixmap(aLabelIcon)); - aControlLay->addWidget(myLabel); - mySpinBox = new ModuleBase_DoubleSpinBox(myContainer); + mySpinBox = new ModuleBase_DoubleSpinBox(this); QString anObjName = QString::fromStdString(attributeID()); mySpinBox->setObjectName(anObjName); @@ -87,9 +85,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, QString aTTip = QString::fromStdString(theData->widgetTooltip()); mySpinBox->setToolTip(aTTip); - aControlLay->addWidget(mySpinBox); - aControlLay->setStretch(1, 1); - + aControlLay->addRow(myLabel, mySpinBox); connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); } diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 957d289a7..a5a666f05 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -48,13 +48,6 @@ Q_OBJECT /// \return a control list virtual QList getControls() const; - /// Returns the internal parent wiget control, that can be shown anywhere - /// \returns the widget - QWidget* getControl() const - { - return myContainer; - } - public slots: // Delayed value chnged: when user starts typing something, // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal @@ -66,9 +59,6 @@ protected: virtual bool storeValue() const; protected: - /// Container for thw widget controls - QWidget* myContainer; - /// Label of the widget QLabel* myLabel; diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 40f7227ca..d606c0bf7 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -70,6 +70,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) return; QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent); + bool isStretchLayout = false; do { //Iterate over each node std::string aWdgType = myWidgetApi->widgetType(); //Create a widget (doublevalue, groupbox, toolbox, etc. @@ -96,8 +97,8 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) do { QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)); QWidget* aPage = new QWidget(aWidget); - ModuleBase_Tools::adjustMargins(aPage); createWidget(aPage); + ModuleBase_Tools::adjustMargins(aPage); if (aWdgType == WDG_SWITCH) { ModuleBase_WidgetSwitch* aSwitch = qobject_cast(aWidget); aSwitch->addPage(aPage, aPageName); @@ -105,22 +106,37 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) QToolBox* aToolbox = qobject_cast(aWidget); aToolbox->addItem(aPage, aPageName); } + } while (myWidgetApi->toNextWidget()); } + if (aWidget && !isStretchLayout) { + isStretchLayout = !hasExpandingControls(aWidget); + } } while (myWidgetApi->toNextWidget()); + if (isStretchLayout) { + aWidgetLay->addStretch(1); + } theParent->setLayout(aWidgetLay); } - -QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent) +bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent) { - ModuleBase_WidgetLabel* aWgt = - new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId); - myModelWidgets.append(aWgt); - return aWgt->getControl(); + bool result = false; + QList aListToCheck; + aListToCheck << theParent; + ModuleBase_ModelWidget* aModelWidget = qobject_cast(theParent); + if(aModelWidget) { + aListToCheck << aModelWidget->getControls(); + } + foreach(QWidget* eachWidget, aListToCheck) { + QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy(); + if(aVPolicy & QSizePolicy::ExpandFlag) { + result = true; + } + } + return result; } - QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType, QWidget* theParent) { @@ -137,12 +153,6 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType } else if (theType == WDG_BOOLVALUE) { result = booleanControl(theParent); - //} else if (theType == WDG_FEATURE_SELECTOR) { - // result = featureSelectorControl(theParent); - - //} else if (theType == WDG_FEATURE_OR_ATTRIBUTE_SELECTOR) { - // result = featureOrAttributeSelectorControl(theParent); - } else if (theType == WDG_DOUBLEVALUE_EDITOR) { result = doubleValueEditor(theParent); @@ -179,9 +189,21 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q result = aGroupBox; } else if (theType == WDG_TOOLBOX) { result = new QToolBox(theParent); + // Dark-grey rounded tabs with button-like border #and bold font + QString css = "QToolBox::tab{background-color:#c8c8c8;" + "border-radius:5px;" + "border:1px inset;" + //"font-weight:700;" + "border-color:#fff #505050 #505050 #fff;}"; + result->setStyleSheet(css); + // default vertical size policy is preferred + QSizePolicy aSizePolicy = result->sizePolicy(); + aSizePolicy.setVerticalPolicy(QSizePolicy::MinimumExpanding); + result->setSizePolicy(aSizePolicy); } else if (theType == WDG_SWITCH) { result = new ModuleBase_WidgetSwitch(theParent); } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) { + // Do nothing for "box" and "case" result = NULL; } #ifdef _DEBUG @@ -190,12 +212,20 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q return result; } +QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent) +{ + ModuleBase_WidgetLabel* aWgt = + new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId); + myModelWidgets.append(aWgt); + return aWgt; +} + QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent) { ModuleBase_WidgetDoubleValue* aDblWgt = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId); myModelWidgets.append(aDblWgt); - return aDblWgt->getControl(); + return aDblWgt; } QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent) @@ -203,7 +233,7 @@ QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent) ModuleBase_WidgetEditor* aWidget = new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId); myModelWidgets.append(aWidget); - return aWidget->getControl(); + return aWidget; } QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent) @@ -211,7 +241,7 @@ QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent) ModuleBase_WidgetShapeSelector* aSelector = new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId); myModelWidgets.append(aSelector); - return aSelector->getControl(); + return aSelector; } QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent) @@ -219,7 +249,7 @@ QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent) ModuleBase_WidgetBoolValue* aBoolWgt = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId); myModelWidgets.append(aBoolWgt); - return aBoolWgt->getControl(); + return aBoolWgt; } QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent) @@ -227,7 +257,7 @@ QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent) ModuleBase_WidgetFileSelector* aFileSelectorWgt = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId); myModelWidgets.append(aFileSelectorWgt); - return aFileSelectorWgt->getControl(); + return aFileSelectorWgt; } QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent) @@ -235,7 +265,7 @@ QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent) ModuleBase_WidgetChoice* aChoiceWgt = new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId); myModelWidgets.append(aChoiceWgt); - return aChoiceWgt->getControl(); + return aChoiceWgt; } QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent) @@ -243,7 +273,7 @@ QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent) ModuleBase_WidgetLineEdit* aLineEditWgt = new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId); myModelWidgets.append(aLineEditWgt); - return aLineEditWgt->getControl(); + return aLineEditWgt; } QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent) @@ -251,7 +281,7 @@ QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent) ModuleBase_WidgetMultiSelector* aMultiselectorWgt = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId); myModelWidgets.append(aMultiselectorWgt); - return aMultiselectorWgt->getControl(); + return aMultiselectorWgt; } QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 1292cec57..93b8443ae 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -40,6 +40,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory /// \param theParent a parent widget void createWidget(QWidget* theParent); + /// Returns list of model widgets QList getModelWidgets() const { @@ -47,6 +48,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory } protected: + /// check if ModuleBase_Widget has expandable widgets in getControls + bool hasExpandingControls(QWidget* theParent); /// Create widget by its type /// \param theType a type /// \param theParent a parent widget diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp index 80e6d670a..354f84547 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp @@ -37,15 +37,14 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent, myTitle = QString::fromStdString(theData->getProperty("title")); myDefaultPath = QString::fromStdString(theData->getProperty("path")); - myMainWidget = new QWidget(theParent); - QGridLayout* aMainLay = new QGridLayout(myMainWidget); + QGridLayout* aMainLay = new QGridLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); - QLabel* aTitleLabel = new QLabel(myTitle, myMainWidget); + QLabel* aTitleLabel = new QLabel(myTitle, this); aTitleLabel->setIndent(1); aMainLay->addWidget(aTitleLabel, 0, 0); - myPathField = new QLineEdit(myMainWidget); + myPathField = new QLineEdit(this); aMainLay->addWidget(myPathField, 1, 0); - QPushButton* aSelectPathBtn = new QPushButton("...", myMainWidget); + QPushButton* aSelectPathBtn = new QPushButton("...", this); aSelectPathBtn->setToolTip(tr("Select file...")); aSelectPathBtn->setMaximumWidth(20); aSelectPathBtn->setMaximumHeight(20); @@ -53,7 +52,7 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent, aMainLay->setColumnStretch(0, 1); myPathField->setMinimumHeight(20); aMainLay->setHorizontalSpacing(1); - myMainWidget->setLayout(aMainLay); + this->setLayout(aMainLay); connect(myPathField, SIGNAL(textChanged(const QString&)), this, SLOT(onPathChanged())); @@ -93,15 +92,10 @@ bool ModuleBase_WidgetFileSelector::restoreValue() return true; } -QWidget* ModuleBase_WidgetFileSelector::getControl() const -{ - return myMainWidget; -} - QList ModuleBase_WidgetFileSelector::getControls() const { QList result; - //QPushButton * aButton = myMainWidget->findChild(); + //QPushButton * aButton = this->findChild(); //result << aButton; result << myPathField; return result; @@ -117,7 +111,7 @@ bool ModuleBase_WidgetFileSelector::isCurrentPathValid() void ModuleBase_WidgetFileSelector::onPathSelectionBtn() { QString aFilter = formatsString(); - QString aFileName = QFileDialog::getOpenFileName(myMainWidget, myTitle, myDefaultPath, aFilter); + QString aFileName = QFileDialog::getOpenFileName(this, myTitle, myDefaultPath, aFilter); if (!aFileName.isEmpty()) { myPathField->setText(aFileName); } diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.h b/src/ModuleBase/ModuleBase_WidgetFileSelector.h index 5a628286d..d9b3337fd 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.h @@ -48,8 +48,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW virtual bool restoreValue(); - QWidget* getControl() const; - virtual QList getControls() const; /// Returns true if a file on the current path in the line edit @@ -79,9 +77,6 @@ protected: /// A control for path input QLineEdit* myPathField; - /// Container - QWidget* myMainWidget; - /// A title of open file dialog box QString myTitle; diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.cpp b/src/ModuleBase/ModuleBase_WidgetLabel.cpp index d5ffd015b..3abae6c7b 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLabel.cpp @@ -7,19 +7,26 @@ #include "ModuleBase_WidgetLabel.h" #include +#include #include +#include ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) + const Config_WidgetAPI* theData, + const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId) { QString aText = QString::fromStdString(theData->getProperty("title")); myLabel = new QLabel(aText, theParent); myLabel->setWordWrap(true); myLabel->setIndent(5); + myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); + QVBoxLayout* aLayout = new QVBoxLayout(this); + ModuleBase_Tools::zeroMargins(aLayout); + aLayout->addWidget(myLabel); + setLayout(aLayout); } ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel() @@ -31,7 +38,3 @@ QList ModuleBase_WidgetLabel::getControls() const return QList(); } -QWidget* ModuleBase_WidgetLabel::getControl() const -{ - return myLabel; -} diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.h b/src/ModuleBase/ModuleBase_WidgetLabel.h index fd0112ff1..17add9310 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.h +++ b/src/ModuleBase/ModuleBase_WidgetLabel.h @@ -40,8 +40,6 @@ Q_OBJECT virtual QList getControls() const; - QWidget* getControl() const; - /// This control doesn't accept focus virtual bool focusTo() { return false; } @@ -58,4 +56,4 @@ private: QLabel* myLabel; }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp b/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp index 91af0aa94..3930efe15 100644 --- a/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include #include @@ -31,16 +31,13 @@ ModuleBase_WidgetLineEdit::ModuleBase_WidgetLineEdit(QWidget* theParent, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId) { - myMainWidget = new QWidget(theParent); - QHBoxLayout* aMainLay = new QHBoxLayout(myMainWidget); + QFormLayout* aMainLay = new QFormLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); QString aTitle = QString::fromStdString(theData->widgetLabel()); - QLabel* aTitleLabel = new QLabel(aTitle, myMainWidget); - aMainLay->addWidget(aTitleLabel); - myLineEdit = new QLineEdit(myMainWidget); - aMainLay->addWidget(myLineEdit); + myLineEdit = new QLineEdit(this); myLineEdit->setMinimumHeight(20); - myMainWidget->setLayout(aMainLay); + aMainLay->addRow(aTitle, myLineEdit); + this->setLayout(aMainLay); connect(myLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged())); } @@ -77,11 +74,6 @@ bool ModuleBase_WidgetLineEdit::restoreValue() return true; } -QWidget* ModuleBase_WidgetLineEdit::getControl() const -{ - return myMainWidget; -} - QList ModuleBase_WidgetLineEdit::getControls() const { QList result; diff --git a/src/ModuleBase/ModuleBase_WidgetLineEdit.h b/src/ModuleBase/ModuleBase_WidgetLineEdit.h index 657b22be0..868d0ee6f 100644 --- a/src/ModuleBase/ModuleBase_WidgetLineEdit.h +++ b/src/ModuleBase/ModuleBase_WidgetLineEdit.h @@ -40,8 +40,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge virtual bool restoreValue(); - QWidget* getControl() const; - virtual QList getControls() const; public slots: @@ -56,9 +54,6 @@ protected: private: /// A line edit control QLineEdit* myLineEdit; - - /// A container widget - QWidget* myMainWidget; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index a11725988..f38b9b7ee 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -41,29 +41,28 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen : ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop), myIsActive(false) { - myMainWidget = new QWidget(theParent); - QGridLayout* aMainLay = new QGridLayout(myMainWidget); + QGridLayout* aMainLay = new QGridLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); - QLabel* aTypeLabel = new QLabel(tr("Type"), myMainWidget); + QLabel* aTypeLabel = new QLabel(tr("Type"), this); aMainLay->addWidget(aTypeLabel, 0, 0); - myTypeCombo = new QComboBox(myMainWidget); + myTypeCombo = new QComboBox(this); // There is no sence to paramerize list of types while we can not parametrize selection mode QString aTypesStr("Vertices Edges Faces Solids"); QStringList aShapeTypes = aTypesStr.split(' '); myTypeCombo->addItems(aShapeTypes); aMainLay->addWidget(myTypeCombo, 0, 1); - QLabel* aListLabel = new QLabel(tr("Selected objects:"), myMainWidget); + QLabel* aListLabel = new QLabel(tr("Selected objects:"), this); aMainLay->addWidget(aListLabel, 1, 0, 1, -1); - myListControl = new QListWidget(myMainWidget); + myListControl = new QListWidget(this); aMainLay->addWidget(myListControl, 2, 0, 2, -1); aMainLay->setRowStretch(2, 1); - aMainLay->addWidget(new QLabel(myMainWidget)); + aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)??? aMainLay->setRowMinimumHeight(3, 20); - myMainWidget->setLayout(aMainLay); + this->setLayout(aMainLay); connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged())); myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this); @@ -135,12 +134,6 @@ bool ModuleBase_WidgetMultiSelector::restoreValue() return false; } -//******************************************************************** -QWidget* ModuleBase_WidgetMultiSelector::getControl() const -{ - return myMainWidget; -} - //******************************************************************** QList ModuleBase_WidgetMultiSelector::getControls() const { diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 3b092d424..e6ad53b24 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -64,10 +64,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Model virtual bool restoreValue(); - /// Returns the internal parent wiget control, that can be shown anywhere - /// \returns the widget - QWidget* getControl() const; - /// Returns list of widget controls /// \return a control list virtual QList getControls() const; @@ -118,9 +114,6 @@ protected slots: /// Combobox of types QComboBox* myTypeCombo; - /// Container - QWidget* myMainWidget; - //TODO: Move into the base of selectors ModuleBase_IWorkshop* myWorkshop; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 81e45ef0a..021d176b2 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -95,25 +96,23 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen : ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop), myIsActive(false) { - myContainer = new QWidget(theParent); - QHBoxLayout* aLayout = new QHBoxLayout(myContainer); + QFormLayout* aLayout = new QFormLayout(this); ModuleBase_Tools::adjustMargins(aLayout); QString aLabelText = QString::fromStdString(theData->widgetLabel()); QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); - myLabel = new QLabel(aLabelText, myContainer); + myLabel = new QLabel(aLabelText, this); if (!aLabelIcon.isEmpty()) myLabel->setPixmap(QPixmap(aLabelIcon)); - aLayout->addWidget(myLabel); QString aToolTip = QString::fromStdString(theData->widgetTooltip()); - myTextLine = new QLineEdit(myContainer); + myTextLine = new QLineEdit(this); myTextLine->setReadOnly(true); myTextLine->setToolTip(aToolTip); myTextLine->installEventFilter(this); - aLayout->addWidget(myTextLine, 1); + aLayout->addRow(myLabel, myTextLine); std::string aTypes = theData->getProperty("shape_types"); myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts); @@ -440,7 +439,7 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate) //******************************************************************** void ModuleBase_WidgetShapeSelector::raisePanel() const { - QWidget* aParent = myContainer->parentWidget(); + QWidget* aParent = this->parentWidget(); QWidget* aLastPanel = 0; while (!aParent->inherits("QDockWidget")) { aLastPanel = aParent; @@ -516,4 +515,4 @@ bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr getControls() const; @@ -151,10 +144,6 @@ Q_OBJECT //----------- Class members ------------- protected: - - /// Container of the widget's control - QWidget* myContainer; - /// Label of the widget QLabel* myLabel; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 960c92ffc..b873d3846 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -430,50 +430,38 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* { XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); XGUI_Workshop* aWorkshop = aConnector->workshop(); + ModuleBase_ModelWidget* aWgt = NULL; if (theType == "sketch-start-label") { - PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId); - aWgt->setWorkshop(aWorkshop); - connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr&)), + PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId); + aLabelWgt->setWorkshop(aWorkshop); + connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr&)), mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr&))); - theModelWidgets.append(aWgt); - return aWgt->getControl(); - + aWgt = aLabelWgt; } else if (theType == "sketch-2dpoint_selector") { - PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId); - aWgt->setWorkshop(aWorkshop); - aWgt->setSketch(mySketchMgr->activeSketch()); - - connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected())); - - theModelWidgets.append(aWgt); - return aWgt->getControl(); - + PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId); + aPointWgt->setWorkshop(aWorkshop); + aPointWgt->setSketch(mySketchMgr->activeSketch()); + connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected())); + aWgt = aPointWgt; } if (theType == "point2ddistance") { - PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId); - aWgt->setWorkshop(aWorkshop); - aWgt->setSketch(mySketchMgr->activeSketch()); - - theModelWidgets.append(aWgt); - return aWgt->getControl(); - + PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId); + aDistanceWgt->setWorkshop(aWorkshop); + aDistanceWgt->setSketch(mySketchMgr->activeSketch()); + aWgt = aDistanceWgt; } if (theType == "sketch_shape_selector") { - PartSet_WidgetShapeSelector* aWgt = + PartSet_WidgetShapeSelector* aShapeSelectorWgt = new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId); - aWgt->setSketcher(mySketchMgr->activeSketch()); - - theModelWidgets.append(aWgt); - return aWgt->getControl(); - + aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch()); + aWgt = aShapeSelectorWgt; } if (theType == "sketch_constraint_shape_selector") { - PartSet_WidgetConstraintShapeSelector* aWgt = + PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt = new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId); - aWgt->setSketcher(mySketchMgr->activeSketch()); - + aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch()); + aWgt = aConstraintShapeSelectorWgt; + } + if(aWgt) theModelWidgets.append(aWgt); - return aWgt->getControl(); - - } else - return 0; + return aWgt; } bool PartSet_Module::isSketchFeatureOperationActive() const diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 60b644e08..114a4b1eb 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -90,6 +90,10 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged())); } + QVBoxLayout* aLayout = new QVBoxLayout(this); + ModuleBase_Tools::zeroMargins(aLayout); + aLayout->addWidget(myGroupBox); + setLayout(aLayout); } void PartSet_WidgetPoint2D::reset() @@ -181,11 +185,6 @@ bool PartSet_WidgetPoint2D::restoreValue() return true; } -QWidget* PartSet_WidgetPoint2D::getControl() const -{ - return myGroupBox; -} - QList PartSet_WidgetPoint2D::getControls() const { QList aControls; diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index de3ab120d..963409c26 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -57,10 +57,6 @@ Q_OBJECT virtual bool restoreValue(); - /// Returns the internal parent wiget control, that can be shown anywhere - /// \returns the widget - QWidget* getControl() const; - /// Returns list of widget controls /// \return a control list virtual QList getControls() const; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index f3001c881..5925437ed 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -37,12 +38,15 @@ #include #include #include +#include PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) - : ModuleBase_ModelWidget(theParent, theData, theParentId), myPreviewDisplayed(false) + : ModuleBase_ModelWidget(theParent, theData, theParentId), + myPreviewDisplayed(false), + myWorkshop(NULL) { myText = QString::fromStdString(theData->getProperty("title")); myLabel = new QLabel("", theParent); @@ -54,6 +58,11 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, mySelectionTimer = new QTimer(this); connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode())); mySelectionTimer->setSingleShot(true); + + QVBoxLayout* aLayout = new QVBoxLayout(this); + ModuleBase_Tools::zeroMargins(aLayout); + aLayout->addWidget(myLabel); + setLayout(aLayout); } PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel() @@ -66,11 +75,6 @@ QList PartSet_WidgetSketchLabel::getControls() const return QList(); } -QWidget* PartSet_WidgetSketchLabel::getControl() const -{ - return myLabel; -} - void PartSet_WidgetSketchLabel::onPlaneSelected() { XGUI_Selection* aSelection = myWorkshop->selector()->selection(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 0fa5c18f0..9d5de2117 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -57,8 +57,6 @@ Q_OBJECT /// \return a control list virtual QList getControls() const; - QWidget* getControl() const; - /// The methiod called when widget is deactivated virtual void deactivate(); diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 0798bbc48..33f1826a7 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -142,9 +142,6 @@ void XGUI_ActionsMgr::updateOnViewSelection() foreach(QString aId, nestedCommands(aFeatureId)) { std::list aValidators; std::list > anArguments; - if (!anArguments.empty()) { - std::list firstArg = anArguments.front(); - } aFactory->validators(aId.toStdString(), aValidators, anArguments); std::list::iterator aValidator = aValidators.begin(); std::list >::iterator aValidatorArgs = anArguments.begin(); diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 348eb2a31..2ff582bb7 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include #include #include @@ -101,7 +103,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) : QWidget(theParent) { QVBoxLayout* aLayout = new QVBoxLayout(this); - aLayout->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::zeroMargins(aLayout); aLayout->setSpacing(0); QFrame* aLabelWgt = new QFrame(this); @@ -112,7 +114,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLayout->addWidget(aLabelWgt); QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt); - aLabelLay->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::zeroMargins(aLabelLay); aLabelLay->setSpacing(0); QLabel* aLbl = new QLabel(aLabelWgt); diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 355614b76..1779431f5 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -11,6 +11,7 @@ #include //#include #include +#include #include #include @@ -19,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -38,16 +39,18 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }"); QWidget* aContent = new QWidget(this); - myMainLayout = new QVBoxLayout(aContent); + myMainLayout = new QGridLayout(aContent); + const int kPanelColumn = 0; + int aPanelRow = 0; myMainLayout->setContentsMargins(3, 3, 3, 3); this->setWidget(aContent); QFrame* aFrm = new QFrame(aContent); - aFrm->setFrameStyle(QFrame::Sunken); + aFrm->setFrameStyle(QFrame::Raised); aFrm->setFrameShape(QFrame::Panel); QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm); - aBtnLay->setContentsMargins(0, 0, 0, 0); - myMainLayout->addWidget(aFrm); + ModuleBase_Tools::zeroMargins(aBtnLay); + myMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn); QStringList aBtnNames; aBtnNames << QString(PROP_PANEL_HELP) @@ -60,10 +63,10 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) aBtnLay->addWidget(aBtn); } aBtnLay->insertStretch(1, 1); - // aBtn->setShortcut(QKeySequence(Qt::Key_Escape)); myCustomWidget = new QWidget(aContent); - myMainLayout->addWidget(myCustomWidget); + myCustomWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + myMainLayout->addWidget(myCustomWidget, aPanelRow, kPanelColumn); setStretchEnabled(true); } @@ -85,32 +88,14 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t { myWidgets = theWidgets; if (theWidgets.empty()) return; - bool isEnableStretch = true; - QList::const_iterator anIt = theWidgets.begin(), aLast = - theWidgets.end(); - for (; anIt != aLast; anIt++) { + QList::const_iterator anIt = theWidgets.begin(); + for (; anIt != theWidgets.end(); anIt++) { connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this, SLOT(activateNextWidget(ModuleBase_ModelWidget*))); connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)), this, SLOT(activateWidget(ModuleBase_ModelWidget*))); - - //ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast(*anIt); - //if (aPointWidget) - // connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this, - // SIGNAL(storedPoint2D(ObjectPtr, const std::string&))) - //} - - if (!isEnableStretch) continue; - foreach(QWidget* eachWidget, (*anIt)->getControls()) { - QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy(); - if(aVPolicy == QSizePolicy::Expanding || - aVPolicy == QSizePolicy::MinimumExpanding) { - isEnableStretch = false; - } - } } - setStretchEnabled(isEnableStretch); ModuleBase_ModelWidget* aLastWidget = theWidgets.last(); if (aLastWidget) { QList aControls = aLastWidget->getControls(); @@ -179,17 +164,10 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled) { - if (myMainLayout->count() == 0) + int aStretchIdx = myMainLayout->rowCount() - 1; + if (aStretchIdx < 0) return; - int aStretchIdx = myMainLayout->count() - 1; - bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL; - QLayoutItem* aChild; - if (isEnabled) { - if (!hasStretch) myMainLayout->addStretch(1); - } else if (hasStretch) { - aChild = myMainLayout->takeAt(aStretchIdx); - delete aChild; - } + myMainLayout->setRowStretch(aStretchIdx, isEnabled ? 1 : 0); } void XGUI_PropertyPanel::activateNextWidget() diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index c70e0aec7..5d1706042 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -19,7 +19,7 @@ class XGUI_ActionsMgr; class QKeyEvent; -class QVBoxLayout; +class QGridLayout; /// Internal name of property panel widget const static char* PROP_PANEL = "property_panel_dock"; @@ -106,7 +106,7 @@ Q_OBJECT private: QWidget* myCustomWidget; QList myWidgets; - QVBoxLayout* myMainLayout; + QGridLayout* myMainLayout; /// Currently active widget ModuleBase_ModelWidget* myActiveWidget; -- 2.39.2