#include <QGraphicsDropShadowEffect>
#include <QColor>
#include <QLabel>
+#include <QFocusEvent>
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
const Config_WidgetAPI* theData,
{
QWidget* aWidget = qobject_cast<QWidget*>(theObject);
if (theEvent->type() == QEvent::FocusIn) {
+ #ifdef _DEBUG
+ // The following two lines are for debugging purpose only
+ QFocusEvent* aFocusEvent = dynamic_cast<QFocusEvent*>(theEvent);
+ bool isWinFocus = aFocusEvent->reason() == Qt::ActiveWindowFocusReason;
+ #endif
if (getControls().contains(aWidget)) {
emit focusInWidget(this);
}
virtual void enableFocusProcessing();
//! Switch On/Off highlighting of the widget
- void setHighlighted(bool isHighlighted);
+ virtual void setHighlighted(bool isHighlighted);
/// Returns the attribute name
/// \returns the string value
}
-void ModuleBase_PageBase::takeFocus()
+bool ModuleBase_PageBase::takeFocus()
{
if(myWidgetList.isEmpty())
- return;
+ return false;
- myWidgetList.first()->focusTo();
+ return myWidgetList.first()->focusTo();
}
QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets()
void addPageWidget(ModuleBase_PageBase* theWidget);
void clearPage();
- void takeFocus();
+ bool takeFocus();
QList<ModuleBase_ModelWidget*> modelWidgets();
void alignToTop();
const int kCol = 0;
const int kRow = myMainLayout->count();
myMainLayout->addWidget(theWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+ myMainLayout->setRowStretch(kRow, 0);
+
}
void ModuleBase_PageGroupBox::placePageWidget(ModuleBase_PageBase* theWidget)
}
const int kCol = 0;
const int kRow = myMainLayout->count();
- myMainLayout->addWidget(aWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+ myMainLayout->addWidget(aWidget, kRow, kCol);
+ myMainLayout->setRowStretch(kRow, 0);
}
QLayout* ModuleBase_PageGroupBox::pageLayout()
const int kCol = 0;
const int kRow = myMainLayout->count();
myMainLayout->addWidget(theWidget, kRow, kCol);
+ myMainLayout->setRowStretch(kRow, 0);
}
void ModuleBase_PageWidget::placePageWidget(ModuleBase_PageBase* theWidget)
}
const int kCol = 0;
const int kRow = myMainLayout->count();
- myMainLayout->addWidget(aWidget, kRow, kCol);//, Qt::AlignTop | Qt::AlignLeft);
+ myMainLayout->addWidget(aWidget, kRow, kCol);
+ myMainLayout->setRowStretch(kRow, 0);
}
QLayout* ModuleBase_PageWidget::pageLayout()
} else if (theType == WDG_SWITCH) {
result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi, myParentId);
- return result;
} else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
// Do nothing for "box" and "case"
#include <ModuleBase_WidgetToolbox.h>
#include <ModuleBase_PageBase.h>
+#include <ModuleBase_ModelWidget.h>
#include <ModuleBase_Tools.h>
#include <ModelAPI_AttributeString.h>
#include <QWidget>
+#include <Qlist>
#include <QVBoxLayout>
ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData,
const std::string& theParentId)
-: ModuleBase_ModelWidget(theParent, theData, theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId),
+ myIsPassFocusToCurrentPage(false)
{
QVBoxLayout* aMainLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aMainLayout);
bool isSignalsBlocked = myToolBox->blockSignals(true);
myToolBox->setCurrentIndex(idx);
myToolBox->blockSignals(isSignalsBlocked);
- focusTo();
return true;
}
QList<QWidget*> ModuleBase_WidgetToolbox::getControls() const
{
- QList<QWidget*> aList;
- aList << myToolBox;
- return aList;
+ QList<QWidget*> aResult;
+ int idx = myToolBox->currentIndex();
+ QList<ModuleBase_ModelWidget*> aModelWidgets = myPages[idx]->modelWidgets();
+ foreach(ModuleBase_ModelWidget* eachModelWidget, aModelWidgets) {
+ aResult << eachModelWidget->getControls();
+ }
+ return aResult;
}
bool ModuleBase_WidgetToolbox::focusTo()
int idx = myToolBox->currentIndex();
if (idx > myPages.count())
return false;
- myPages[idx]->takeFocus();
- repaint();
- return true;
+ return myPages[idx]->takeFocus();
+}
+
+void ModuleBase_WidgetToolbox::setHighlighted(bool)
+{
+ //page containers sould not be highlighted, do nothing
}
+void ModuleBase_WidgetToolbox::enableFocusProcessing()
+{
+ myIsPassFocusToCurrentPage = true;
+}
+
+
void ModuleBase_WidgetToolbox::activateCustom()
{
+ // activate current page
+ focusTo();
}
bool ModuleBase_WidgetToolbox::storeValueCustom() const
void ModuleBase_WidgetToolbox::onPageChanged()
{
storeValue();
- focusTo();
+ if (myIsPassFocusToCurrentPage) focusTo();
}
virtual bool restoreValue();
virtual QList<QWidget*> getControls() const;
virtual bool focusTo();
+ virtual void setHighlighted(bool isHighlighted);
+ virtual void enableFocusProcessing();
int addPage(ModuleBase_PageBase* theWidget,
const QString& theName, const QString& theCaseId);
void onPageChanged();
private:
+ bool myIsPassFocusToCurrentPage;
QToolBox* myToolBox;
QStringList myCaseIds;
QList<ModuleBase_PageBase*> myPages;
QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
{
- return QList<QWidget*>();
+ QList<QWidget*> aResult;
+ aResult << myLabel;
+ return aResult;
}
void PartSet_WidgetSketchLabel::onPlaneSelected()
}
+bool PartSet_WidgetSketchLabel::focusTo()
+{
+ myLabel->setFocus();
+ return true;
+}
+
+void PartSet_WidgetSketchLabel::enableFocusProcessing()
+{
+ myLabel->installEventFilter(this);
+}
+
void PartSet_WidgetSketchLabel::activateCustom()
{
std::shared_ptr<GeomAPI_Pln> aPlane = plane();
std::shared_ptr<GeomAPI_Pln> plane() const;
/// This control accepts focus
- virtual bool focusTo() { return true; }
+ virtual bool focusTo();
+ virtual void setHighlighted(bool) { /*do nothing*/ };
+ virtual void enableFocusProcessing();
signals:
/// Signal on plane selection
{
myWidgets = theWidgets;
if (theWidgets.empty()) return;
- QList<ModuleBase_ModelWidget*>::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*)));
+ foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
+ connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
+ this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
+ connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
+ this, SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
+ connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)),
+ this, SIGNAL(keyReleased(QKeyEvent*)));
}
ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
if (aLastWidget) {
}
// Normaly focusTo is enough to activate widget
// here is a special case on mouse click in the viewer
- //if(aNextWidget == NULL) {
+ if(aNextWidget == NULL) {
activateWidget(aNextWidget);
- //}
+ }
}
void XGUI_PropertyPanel::activateNextWidget()
void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
{
// Avoid activation of already actve widget. It could happen on focusIn event many times
- if (theWidget == myActiveWidget)
+ if (theWidget == myActiveWidget) {
return;
+ }
if(myActiveWidget) {
myActiveWidget->deactivate();
myActiveWidget->setHighlighted(false);
}
if(theWidget) {
- if (theWidget)
- emit beforeWidgetActivated(theWidget);
- theWidget->activate();
+ emit beforeWidgetActivated(theWidget);
theWidget->setHighlighted(true);
+ theWidget->activate();
}
myActiveWidget = theWidget;
- if (myActiveWidget)
+ if (myActiveWidget) {
emit widgetActivated(theWidget);
- else if (!isEditingMode())
+ } else if (!isEditingMode()) {
emit noMoreWidgets();
+ }
}
void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)