Sketcher: Prevent renaming interruption when hovering task elements. (#20458)

* Sketcher: Prevent renaming interruption when hovering task elements.

Fixes #11842.

* Sketcher: Refactored input focus check based on PR feedback (PR #20458)

* Update src/Mod/Sketcher/Gui/TaskSketcherElements.cpp

---------

Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
This commit is contained in:
Rafael Pronto
2025-03-31 18:45:33 +01:00
committed by GitHub
parent 93ae9737ed
commit c180ec19aa
2 changed files with 16 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
#ifndef _PreComp_
#include <QContextMenuEvent>
#include <QImage>
#include <QLineEdit>
#include <QMenu>
#include <QPainter>
#include <QPixmap>
@@ -1694,8 +1695,17 @@ void TaskSketcherElements::onListWidgetElementsItemPressed(QListWidgetItem* it)
ui->listWidgetElements->repaint();
}
bool TaskSketcherElements::hasInputWidgetFocused()
{
QWidget* focusedWidget = QApplication::focusWidget();
return qobject_cast<QLineEdit*>(focusedWidget) != nullptr;
}
void TaskSketcherElements::onListWidgetElementsItemEntered(QListWidgetItem* item)
{
if (hasInputWidgetFocused()) {
return;
}
ui->listWidgetElements->setFocus();
focusItemIndex = ui->listWidgetElements->row(item);
@@ -1703,6 +1713,10 @@ void TaskSketcherElements::onListWidgetElementsItemEntered(QListWidgetItem* item
void TaskSketcherElements::onListWidgetElementsMouseMoveOnItem(QListWidgetItem* it)
{
if (hasInputWidgetFocused()) {
return;
}
ElementItem* item = static_cast<ElementItem*>(it);
if (!item

View File

@@ -125,6 +125,8 @@ public:
/// Observer message from the Selection
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
bool hasInputWidgetFocused();
private:
void slotElementsChanged();
void updateVisibility();