diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt
index 6442c89e84..76117d2ea5 100644
--- a/src/Gui/CMakeLists.txt
+++ b/src/Gui/CMakeLists.txt
@@ -526,7 +526,7 @@ SET(Dialog_Customize_CPP_SRCS
DlgKeyboardImp.cpp
DlgToolbarsImp.cpp
QListWidgetCustom.cpp
- QListWidgetDragBugFix.cpp
+ ListWidgetDragBugFix.cpp
)
SET(Dialog_Customize_HPP_SRCS
DlgActionsImp.h
@@ -537,7 +537,7 @@ SET(Dialog_Customize_HPP_SRCS
DlgKeyboardImp.h
DlgToolbarsImp.h
QListWidgetCustom.h
- QListWidgetDragBugFix.h
+ ListWidgetDragBugFix.h
)
SET(Dialog_Customize_SRCS
${Dialog_Customize_CPP_SRCS}
diff --git a/src/Gui/DlgSettingsWorkbenches.ui b/src/Gui/DlgSettingsWorkbenches.ui
index 47d48642c8..a92c528dda 100644
--- a/src/Gui/DlgSettingsWorkbenches.ui
+++ b/src/Gui/DlgSettingsWorkbenches.ui
@@ -30,7 +30,7 @@
<html><head/><body><p>You can enable, disable and reorder workbenches (requires restart). Additional workbenches can be installed through the addon manager.</p><p>
-Your currently system has the following workbenches:</p></body></html>
+Currently, your system has the following workbenches:</p></body></html>
true
@@ -38,7 +38,7 @@ Your currently system has the following workbenches:</p></body></
-
-
+
-
@@ -116,9 +116,9 @@ after FreeCAD launches
- QListWidgetDragBugFix
+ ListWidgetDragBugFix
QListWidget
-
+
diff --git a/src/Gui/DlgSettingsWorkbenchesImp.cpp b/src/Gui/DlgSettingsWorkbenchesImp.cpp
index f8a1cafb7a..8014bebd26 100644
--- a/src/Gui/DlgSettingsWorkbenchesImp.cpp
+++ b/src/Gui/DlgSettingsWorkbenchesImp.cpp
@@ -54,6 +54,14 @@ DlgSettingsWorkbenchesImp::DlgSettingsWorkbenchesImp( QWidget* parent )
, ui(new Ui_DlgSettingsWorkbenches)
{
ui->setupUi(this);
+
+ ui->wbList->setDragDropMode(QAbstractItemView::InternalMove);
+ ui->wbList->setSelectionMode(QAbstractItemView::SingleSelection);
+ ui->wbList->viewport()->setAcceptDrops(true);
+ ui->wbList->setDropIndicatorShown(true);
+ ui->wbList->setDragEnabled(true);
+ ui->wbList->setDefaultDropAction(Qt::MoveAction);
+
connect(ui->AutoloadModuleCombo, QOverload::of(&QComboBox::activated), this, [this](int index) { onStartWbChangedClicked(index); });
}
@@ -207,13 +215,6 @@ void DlgSettingsWorkbenchesImp::buildWorkbenchList()
QStringList enabledWbs = getEnabledWorkbenches();
QStringList disabledWbs = getDisabledWorkbenches();
- ui->wbList->setDragDropMode(QAbstractItemView::InternalMove);
- ui->wbList->setSelectionMode(QAbstractItemView::SingleSelection);
- ui->wbList->viewport()->setAcceptDrops(true);
- ui->wbList->setDropIndicatorShown(true);
- ui->wbList->setDragEnabled(true);
- ui->wbList->setDefaultDropAction(Qt::MoveAction);
-
//First we add the enabled wbs in their saved order.
for (const auto& wbName : enabledWbs) {
if (workbenches.contains(wbName)) {
diff --git a/src/Gui/QListWidgetDragBugFix.h b/src/Gui/ListWidgetDragBugFix.cpp
similarity index 74%
rename from src/Gui/QListWidgetDragBugFix.h
rename to src/Gui/ListWidgetDragBugFix.cpp
index 6b19195566..23f5a11574 100644
--- a/src/Gui/QListWidgetDragBugFix.h
+++ b/src/Gui/ListWidgetDragBugFix.cpp
@@ -20,23 +20,31 @@
* *
***************************************************************************/
-#ifndef QLISTWIDGETDRAGBUGFIX_HPP
-#define QLISTWIDGETDRAGBUGFIX_HPP
-
-#include
-#include
-
-
-class QListWidgetDragBugFix : public QListWidget
-{
- Q_OBJECT
-
-public:
- QListWidgetDragBugFix(QWidget *parent);
- ~QListWidgetDragBugFix() override;
-
-protected:
- void dragMoveEvent(QDragMoveEvent *e) override;
-};
-
+#include "PreCompiled.h"
+#ifndef _PreComp_
+# include
#endif
+
+#include "ListWidgetDragBugFix.h"
+
+
+ListWidgetDragBugFix::ListWidgetDragBugFix(QWidget * parent)
+ : QListWidget(parent)
+{
+}
+
+ListWidgetDragBugFix::~ListWidgetDragBugFix()
+{
+}
+
+void ListWidgetDragBugFix::dragMoveEvent(QDragMoveEvent *e)
+{
+ if ((row(itemAt(e->pos())) == currentRow() + 1)
+ || (currentRow() == count() - 1 && row(itemAt(e->pos())) == -1)) {
+ e->ignore();
+ return;
+ }
+ QListWidget::dragMoveEvent(e);
+}
+
+#include "moc_ListWidgetDragBugFix.cpp"
diff --git a/src/Gui/QListWidgetDragBugFix.cpp b/src/Gui/ListWidgetDragBugFix.h
similarity index 61%
rename from src/Gui/QListWidgetDragBugFix.cpp
rename to src/Gui/ListWidgetDragBugFix.h
index 71f864f4e4..2af0b6fb52 100644
--- a/src/Gui/QListWidgetDragBugFix.cpp
+++ b/src/Gui/ListWidgetDragBugFix.h
@@ -20,39 +20,30 @@
* *
***************************************************************************/
-#include "PreCompiled.h"
-#ifndef _PreComp_
-# include
+#ifndef QLISTWIDGETDRAGBUGFIX_HPP
+#define QLISTWIDGETDRAGBUGFIX_HPP
+
+#include
+#include
+
+ /* Qt has a recent bug (2023, https://bugreports.qt.io/browse/QTBUG-100128)
+ * where the items disappears in certain conditions when drag and dropping.
+ * Here we prevent the situation where this happens.
+ * 1 - If the item is dropped on the item below such that the item doesn't move (ie superior half of the below item)
+ * 2 - The item is the last one and user drop it on the empty space below.
+ * In both those cases the item widget was lost.
+ * When Qt solve this bug, this class should not be required anymore.
+ */
+class ListWidgetDragBugFix : public QListWidget
+{
+ Q_OBJECT
+
+public:
+ explicit ListWidgetDragBugFix(QWidget *parent);
+ ~ListWidgetDragBugFix() override;
+
+protected:
+ void dragMoveEvent(QDragMoveEvent *e) override;
+};
+
#endif
-
-#include "QListWidgetDragBugFix.h"
-
-
-QListWidgetDragBugFix::QListWidgetDragBugFix(QWidget * parent)
- : QListWidget(parent)
-{
-}
-
-QListWidgetDragBugFix::~QListWidgetDragBugFix()
-{
-}
-
-/* Qt has a recent bug (2023, https://bugreports.qt.io/browse/QTBUG-100128)
-* where the items disappears in certain conditions when drag and dropping.
-* Here we prevent the situation where this happens.
-* 1 - If the item is dropped on the item below such that the item doesn't move (ie superior half of the below item)
-* 2 - The item is the last one and user drop it on the empty space below.
-* In both those cases the item widget was lost.
- */
-void QListWidgetDragBugFix::dragMoveEvent(QDragMoveEvent *e)
-{
- if ((row(itemAt(e->pos())) == currentRow() + 1)
- || (currentRow() == count() - 1 && row(itemAt(e->pos())) == -1)) {
- e->ignore();
- }
- else {
- QListWidget::dragMoveEvent(e);
- }
-}
-
-#include "moc_QListWidgetDragBugFix.cpp"