Preferences: Workbench: Change the QListWidgetDragBug name to ListWidgetDragBug. Move the wbList setXxx() to ctor. Fix the 'Currently, your...'
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><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></string>
|
||||
Currently, your system has the following workbenches:</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
@@ -38,7 +38,7 @@ Your currently system has the following workbenches:</p></body></
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QListWidgetDragBugFix" name="wbList"/>
|
||||
<widget class="ListWidgetDragBugFix" name="wbList"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
@@ -116,9 +116,9 @@ after FreeCAD launches</string>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QListWidgetDragBugFix</class>
|
||||
<class>ListWidgetDragBugFix</class>
|
||||
<extends>QListWidget</extends>
|
||||
<header>QListWidgetDragBugFix.h</header>
|
||||
<header>ListWidgetDragBugFix.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
||||
@@ -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<int>::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)) {
|
||||
|
||||
@@ -20,23 +20,31 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QLISTWIDGETDRAGBUGFIX_HPP
|
||||
#define QLISTWIDGETDRAGBUGFIX_HPP
|
||||
|
||||
#include <QDragMoveEvent>
|
||||
#include <QListWidget>
|
||||
|
||||
|
||||
class QListWidgetDragBugFix : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QListWidgetDragBugFix(QWidget *parent);
|
||||
~QListWidgetDragBugFix() override;
|
||||
|
||||
protected:
|
||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||
};
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QDragMoveEvent>
|
||||
#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"
|
||||
@@ -20,39 +20,30 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QDragMoveEvent>
|
||||
#ifndef QLISTWIDGETDRAGBUGFIX_HPP
|
||||
#define QLISTWIDGETDRAGBUGFIX_HPP
|
||||
|
||||
#include <QDragMoveEvent>
|
||||
#include <QListWidget>
|
||||
|
||||
/* 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"
|
||||
Reference in New Issue
Block a user