Gui: Fix using context-menu of ExpressionLineEdit

If for the DlgExpressionInput the user config parameter 'NoSystemBsckground' is set to True it's not used as a normal dialog but as a pop-up window.
In this mode the context-menu of the ExpressionLineEdit isn't working. A previous commit (a3036d16f1) fixed a crash but not this issue.

For Qt4 DlgExpressionInput has overridden the eventFilter() to handle using the context-menu but this is not working any more for Qt5 or Qt6.
Luckily, it has appeared that with Qt5 and Qt6 it works out-of-the box now and the event filter is not needed any more.
This commit is contained in:
wmayer
2024-03-09 19:04:02 +01:00
committed by wwmayer
parent 2ce903a46c
commit 2cdc94e15c
2 changed files with 0 additions and 35 deletions

View File

@@ -90,8 +90,6 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path,
#endif
setAttribute(Qt::WA_NoSystemBackground, true);
setAttribute(Qt::WA_TranslucentBackground, true);
qApp->installEventFilter(this);
}
else {
ui->expression->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -109,7 +107,6 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path,
DlgExpressionInput::~DlgExpressionInput()
{
qApp->removeEventFilter(this);
delete ui;
}
@@ -282,34 +279,5 @@ void DlgExpressionInput::show()
ui->expression->selectAll();
}
void DlgExpressionInput::showEvent(QShowEvent* ev)
{
QDialog::showEvent(ev);
}
bool DlgExpressionInput::eventFilter(QObject *obj, QEvent *ev)
{
// if the user clicks on a widget different to this
if (ev->type() == QEvent::MouseButtonPress && obj != this) {
// Since the widget has a transparent background we cannot rely
// on the size of the widget. Instead, it must be checked if the
// cursor is on this or an underlying widget or outside.
if (!underMouse()) {
// if the expression fields context-menu is open do not close the dialog
auto menu = qobject_cast<QMenu*>(obj);
if (menu && menu->parentWidget() == ui->expression) {
return false;
}
bool on = ui->expression->completerActive();
// Do this only if the completer is not shown
if (!on) {
qApp->removeEventFilter(this);
reject();
}
}
}
return false;
}
#include "moc_DlgExpressionInput.cpp"