const Config_WidgetAPI* theData,
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId),
- myWorkshop(theWorkshop)
+ myWorkshop(theWorkshop), myIsActive(false)
{
myContainer = new QWidget(theParent);
QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
myTextLine = new QLineEdit(myContainer);
myTextLine->setReadOnly(true);
myTextLine->setToolTip(aToolTip);
+ processFocus(myTextLine);
myTextLine->installEventFilter(this);
myBasePalet = myTextLine->palette();
aLayout->addWidget(myTextLine, 1);
- myActivateBtn = new QToolButton(myContainer);
- myActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
- myActivateBtn->setCheckable(true);
- myActivateBtn->setToolTip(tr("Activate/Deactivate selection"));
- connect(myActivateBtn, SIGNAL(toggled(bool)), this, SLOT(activateSelection(bool)));
-
- aLayout->addWidget(myActivateBtn);
-
std::string aTypes = theData->getProperty("shape_types");
myShapeTypes = QString(aTypes.c_str()).split(' ');
}
QList<QWidget*> aControls;
aControls.append(myLabel);
aControls.append(myTextLine);
- aControls.append(myActivateBtn);
return aControls;
}
mySelectedObject = aObject;
if (mySelectedObject) {
updateSelectionName();
- myActivateBtn->setChecked(false);
raisePanel();
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
} else {
myTextLine->setText("");
}
+ activateSelection(false);
emit valuesChanged();
emit focusOutWidget(this);
}
{
if (mySelectedObject) {
std::string aName = mySelectedObject->data()->name();
-
myTextLine->setText(QString::fromStdString(aName));
- } else
- myTextLine->setText("");
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::enableOthersControls(bool toEnable) const
-{
- QWidget* aParent = myContainer->parentWidget();
- QList<QWidget*> aChldList = aParent->findChildren<QWidget*>();
- foreach(QWidget* aWgt, aChldList)
- {
- if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine)
- && (aWgt != myContainer))
- aWgt->setEnabled(toEnable);
+ } else {
+ if (myIsActive)
+ myTextLine->setText(tr("Select an object"));
+ else
+ myTextLine->setText(tr("No object selected"));
}
}
+
//********************************************************************
void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
{
- enableOthersControls(!toActivate);
- //myTextLine->setEnabled(toActivate);
- if (toActivate)
+ myIsActive = toActivate;
+ if (myIsActive)
myTextLine->setPalette(myBasePalet);
else
myTextLine->setPalette(myInactivePalet);
+ updateSelectionName();
- if (toActivate)
+ if (myIsActive)
connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
else
disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-
- myActivateBtn->setDown(toActivate);
}
//********************************************************************
//********************************************************************
bool ModuleBase_WidgetShapeSelector::focusTo()
{
- myActivateBtn->setChecked(true);
+ activateSelection(true);
return true;
}
+
+//********************************************************************
+bool ModuleBase_WidgetShapeSelector::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+ if (theObj == myTextLine) {
+ if (theEvent->type() == QEvent::FocusIn)
+ activateSelection(true);
+ }
+ return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
+}
\ No newline at end of file