obs-studio/UI/focus-list.cpp
Clayton Groeneveld f2f4582141 UI: Add ability to reorder filters by drag & drop
This adds the ability for filters to be dragged and dropped
to be reordered, similar to scenes and sources.
2023-06-21 15:33:48 -07:00

28 lines
597 B
C++

#include "focus-list.hpp"
#include <QDragMoveEvent>
FocusList::FocusList(QWidget *parent) : QListWidget(parent) {}
void FocusList::focusInEvent(QFocusEvent *event)
{
QListWidget::focusInEvent(event);
emit GotFocus();
}
void FocusList::dragMoveEvent(QDragMoveEvent *event)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPoint pos = event->position().toPoint();
#else
QPoint pos = event->pos();
#endif
int itemRow = row(itemAt(pos));
if ((itemRow == currentRow() + 1) ||
(currentRow() == count() - 1 && itemRow == -1))
event->ignore();
else
QListWidget::dragMoveEvent(event);
}