// Author: Natalia ERMOLAEVA
#include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_Tools.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_Attribute.h>
for (; anIt != aLast && !isFocusAccepted; anIt++) {
QWidget* aWidget = *anIt;
if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) {
- aWidget->setFocus();
+ ModuleBase_Tools::setFocus(aWidget, "ModuleBase_ModelWidget::focusTo()");
isFocusAccepted = true;
}
}
const double tolerance = 1e-7;
+//#define DEBUG_ACTIVATE_WINDOW
+//#define DEBUG_SET_FOCUS
namespace ModuleBase_Tools {
theLayout->setSpacing(5);
}
+void activateWindow(QWidget* theWidget, const QString& theInfo)
+{
+ theWidget->activateWindow();
+
+#ifdef DEBUG_ACTIVATE_WINDOW
+ qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str());
+#endif
+}
+
+void setFocus(QWidget* theWidget, const QString& theInfo)
+{
+ theWidget->setFocus();
+
+#ifdef DEBUG_SET_FOCUS
+ qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str());
+#endif
+}
+
QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
{
QImage anIcon(theIcon);
MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
+/*
+ * Calls the same-named Qt method for the given widget.
+ * It sets the top-level widget containing this widget to be the active window.
+ * An active window is a visible top-level window that has the keyboard input focus.
+ * \param theWidget a widget to be activated
+ * \param theIndo a debug information
+ */
+MODULEBASE_EXPORT void activateWindow(QWidget* theWidget, const QString& theInfo = QString());
+
+/*
+ * Calls the same-named Qt method for the given widget.
+ * Gives the keyboard input focus to this widget (or its focus proxy) if this widget or
+ * one of its parents is the active window.
+ * \param theWidget a widget to be activated
+ * \param theIndo a debug information
+ */
+MODULEBASE_EXPORT void setFocus(QWidget* theWidget, const QString& theInfo = QString());
/**
* \ingroup GUI
bool ModuleBase_WidgetChoice::focusTo()
{
if (myCombo)
- myCombo->setFocus();
+ ModuleBase_Tools::setFocus(myCombo, "ModuleBase_WidgetChoice::focusTo()");
else
return false;
return true;
aLay->addWidget(anEditor);
- anEditor->setFocus();
+ ModuleBase_Tools::setFocus(anEditor, "ModuleBase_WidgetEditor::editedValue");
anEditor->selectAll();
QObject::connect(anEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept()));
// Set focus to List control in order to make possible
// to use Tab key for transfer the focus to next widgets
myListControl->setCurrentRow(myListControl->model()->rowCount() - 1);
- myListControl->setFocus();
+ ModuleBase_Tools::setFocus(myListControl,
+ "ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()");
}
//********************************************************************
bool PartSet_WidgetSketchLabel::focusTo()
{
- myStackWidget->setFocus();
+ ModuleBase_Tools::setFocus(myStackWidget, "PartSet_WidgetSketchLabel::focusTo()");
return true;
}
const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity
-//#define WORKAROUND_691
-
//#define DEBUG_ACTIVATE_OBJECTS
//#define DEBUG_DEACTIVATE
//#define DEBUG_ACTIVATE_AIS
arg(!isEqualShapes || isCustomized).arg(isEqualShapes).arg(isCustomized).toStdString().c_str());
#endif
if (!isEqualShapes || isCustomized) {
-#ifdef WORKAROUND_691
- // this is a workaround for OCCT 6.9.1, selection area is wrong
- // on sketch and 3D features
- aContext->RecomputePrsOnly (aAISIO, false);
- aContext->SelectionManager()->RecomputeSelection (aAISIO, true);
- aContext->LocalContext()->ClearOutdatedSelection (aAISIO, false);
-#else
aContext->Redisplay(aAISIO, false);
-#endif
aRedisplayed = true;
#ifdef DEBUG_FEATURE_REDISPLAY
qDebug(" Redisplay happens");
*/
#include <XGUI_ErrorDialog.h>
+#include <ModuleBase_Tools.h>
+
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QLabel>
if (!isVisible()) {
show();
raise();
- activateWindow();
+ ModuleBase_Tools::activateWindow(this, "XGUI_ErrorDialog::addError");
}
}
QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
bool isFoundWidget = false;
- activateWindow();
+ ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
for (; anIt != aLast; anIt++) {
ModuleBase_ModelWidget* aCurrentWidget = *anIt;
if (isFoundWidget || !theWidget) {
for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++)
aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
if (aFirstControl)
- aFirstControl->setFocus();
+ ModuleBase_Tools::setFocus(aFirstControl, "XGUI_PropertyPanel::focusNextPrevChild()");
isChangedFocus = true;
}
else {
for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--)
aLastControl = myWidgets[i]->getControlAcceptingFocus(false);
if (aLastControl)
- aLastControl->setFocus();
+ ModuleBase_Tools::setFocus(aLastControl, "XGUI_PropertyPanel::focusNextPrevChild()");
isChangedFocus = true;
}
else {
aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
if (aFirstControl && aFirstControl->hasFocus()) {
QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
- aCancelBtn->setFocus();
+ ModuleBase_Tools::setFocus(aCancelBtn, "XGUI_PropertyPanel::focusNextPrevChild()");
isChangedFocus = true;
}
}
void XGUI_PropertyPanel::setFocusOnOkButton()
{
QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
- anOkBtn->setFocus();
+ ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
}
void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
// in order to operation manager could process key events of the panel.
// otherwise they are ignored. It happens only if the same(activateWindow) is
// not happened by property panel activation(e.g. resume operation of Sketch)
- myPropertyPanel->activateWindow();
- myPropertyPanel->setFocus();
+ ModuleBase_Tools::activateWindow(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()");
+ ModuleBase_Tools::setFocus(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()");
}
//******************************************************
// are processed by this console. For example Undo actions.
// It is possible that this code is to be moved to NewGeom package
QMainWindow* aDesktop = desktop();
- aDesktop->activateWindow();
- aDesktop->setFocus();
+ ModuleBase_Tools::activateWindow(aDesktop, "XGUI_Workshop::hidePropertyPanel()");
+ ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::showPropertyPanel()");
}
//******************************************************