obs-studio/UI/scene-tree.hpp
gxalpha 3e4bbe85c8 UI: Remove workaround for current scene being deselectable on Qt 6.4.3+
Qt 6.2 introduced an issue where SingleSelection item views would
deselect the current item if the user clicked on empty area in the
widget.
This was very confusing in the scene tree as it was now possible to
unselect the current scene. A workaround for this in OBS was added in
08e4ee6 and expanded on in dc30cf0, but being quite hacky it never was
the perfect solution.
I since dug into Qt and fixed the issue upstream in qt/qtbase@f11e5435c7
for Qt 6.4.3 and newer, so we can remove the workaround when using those
versions (with the long term goal of removing the code altogether).
2023-02-11 16:01:27 -08:00

50 lines
1.3 KiB
C++

#pragma once
#include <QListWidget>
#include <QEvent>
#include <QItemDelegate>
class SceneTree : public QListWidget {
Q_OBJECT
Q_PROPERTY(int gridItemWidth READ GetGridItemWidth WRITE
SetGridItemWidth DESIGNABLE true)
Q_PROPERTY(int gridItemHeight READ GetGridItemHeight WRITE
SetGridItemHeight DESIGNABLE true)
bool gridMode = false;
int maxWidth = 150;
int itemHeight = 24;
public:
void SetGridMode(bool grid);
bool GetGridMode();
void SetGridItemWidth(int width);
void SetGridItemHeight(int height);
int GetGridItemWidth();
int GetGridItemHeight();
explicit SceneTree(QWidget *parent = nullptr);
private:
void RepositionGrid(QDragMoveEvent *event = nullptr);
protected:
virtual bool eventFilter(QObject *obj, QEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override;
virtual void startDrag(Qt::DropActions supportedActions) override;
virtual void dropEvent(QDropEvent *event) override;
virtual void dragMoveEvent(QDragMoveEvent *event) override;
virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
virtual void rowsInserted(const QModelIndex &parent, int start,
int end) override;
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 3)
virtual void
selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) override;
#endif
signals:
void scenesReordered();
};