File indexing completed on 2024-04-14 04:46:16
0001 /* 0002 SPDX-FileCopyrightText: 2019 Jean-Baptiste Mardelle <jb@kdenlive.org> 0003 This file is part of Kdenlive. See www.kdenlive.org. 0004 0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #pragma once 0009 0010 #include <QScrollArea> 0011 #include <QToolButton> 0012 0013 /** @class DragButton 0014 @brief A draggable QToolButton subclass 0015 */ 0016 class DragButton : public QToolButton 0017 { 0018 Q_OBJECT 0019 0020 public: 0021 explicit DragButton(int ix, const QString &tag, const QString &description = QString(), QWidget *parent = nullptr); 0022 const QString &tag() const; 0023 const QString &description() const; 0024 0025 private: 0026 QPoint m_dragStartPosition; 0027 /** @brief the color tag */ 0028 QString m_tag; 0029 /** @brief the tag description */ 0030 QString m_description; 0031 /** @brief True if a drag action is in progress */ 0032 bool m_dragging; 0033 0034 protected: 0035 void mousePressEvent(QMouseEvent *event) override; 0036 void mouseMoveEvent(QMouseEvent *event) override; 0037 void mouseReleaseEvent(QMouseEvent *event) override; 0038 0039 Q_SIGNALS: 0040 void switchTag(const QString &tag, bool add); 0041 }; 0042 0043 /** @class TagWidget 0044 @brief The tag widget takes care context menu tagging 0045 */ 0046 class TagWidget : public QWidget 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 explicit TagWidget(QWidget *parent = nullptr); 0052 void setTagData(const QString &tagData = QString()); 0053 void rebuildTags(const QMap<int, QStringList> &newTags); 0054 0055 private: 0056 QList<DragButton *> tags; 0057 void showTagsConfig(); 0058 0059 Q_SIGNALS: 0060 void switchTag(const QString &tag, bool add); 0061 void updateProjectTags(const QMap<int, QStringList> &oldTags, const QMap<int, QStringList> &newTags); 0062 };