28#include <MltConsumer.h>
37class QAbstractItemModel;
41class QSortFilterProxyModel;
47class PlaylistIconView;
49class ElementsDock :
public QDockWidget
62 explicit ElementsDock(QWidget *parent =
nullptr);
68 QMimeData *buildMimeData(
const QString &sourcePath,
69 const QString &categoryName,
71 bool isSoundEffect =
false,
72 bool makeUnique =
false,
73 QString *destPath =
nullptr,
74 bool *didCreate =
nullptr);
77 void resizeEvent(QResizeEvent *event)
override;
78 bool eventFilter(QObject *watched, QEvent *event)
override;
84 bool autoFilter{
false};
85 ElementsModel *model{
nullptr};
86 QSortFilterProxyModel *proxyModel{
nullptr};
87 PlaylistIconView *view{
nullptr};
95 bool autoFilter{
false};
97 bool makeUnique{
false};
99 bool valid()
const {
return pageIndex >= 0 && !filePath.isEmpty(); }
102 void setupCategoryPage(
103 Page page,
const QString &name,
const QIcon &icon,
bool autoFilter,
const QDir &dir);
104 void setupSearchPage();
105 void showSearchOrCategory();
106 void connectView(PlaylistIconView *view);
107 QModelIndex sourceIndex(
const QSortFilterProxyModel *proxy,
const QModelIndex &viewIndex)
const;
108 int pageIndexForModel(
const QAbstractItemModel *model)
const;
109 int pageIndexForView(
const PlaylistIconView *view)
const;
110 ElementPolicy policyFor(
const PlaylistIconView *view,
const QModelIndex &viewIndex)
const;
111 void openElement(
const ElementPolicy &policy);
112 void previewElement(
const ElementPolicy &policy);
113 void startDrag(PlaylistIconView *view);
114 PlaylistIconView *viewForViewport(QObject *watched)
const;
115 void updateToolbarStyle();
116 void stopHoverPreview();
117 void stopAudioPreview();
118 void startAudioPreview(
const QString &filePath);
119 void startHoverAnimation(
const QModelIndex &sourceIndex,
const QString &webpPath);
120 QString destPath(
const QString &sourcePath,
const QString &categoryName)
const;
121 Mlt::Producer *copyAndCreateProducer(
const QString &sourcePath,
122 const QString &categoryName,
124 bool isSoundEffect =
false,
125 bool makeUnique =
false,
126 QString *destPath =
nullptr,
127 bool *didCreate =
nullptr);
128 static void attachSizeFilter(Mlt::Producer *producer, QSize fixedSize = QSize());
129 static QIcon makeTextIcon(
const QString &text,
const QColor &color = QColor());
131 QWidget *m_categoryToolbar{
nullptr};
132 LineEditClear *m_searchField{
nullptr};
133 QActionGroup *m_categoryGroup{
nullptr};
134 QStackedWidget *m_stack{
nullptr};
135 QList<CategoryPage> m_pages;
136 QSortFilterProxyModel *m_searchProxy{
nullptr};
137 PlaylistIconView *m_searchView{
nullptr};
138 int m_searchPageIndex{-1};
139 int m_currentPage{0};
141 QMovie *m_activeMovie{
nullptr};
142 QTimer *m_previewTimer{
nullptr};
143 QString m_previewFilePath;
144 QPersistentModelIndex m_hoveredProxyIndex;
145 QPersistentModelIndex m_hoveredSourceIndex;
146 ElementsModel *m_hoveredModel{
nullptr};
147 QPoint m_dragStartPos;
148 std::unique_ptr<Mlt::Consumer> m_audioConsumer;