File indexing completed on 2024-12-01 04:29:22
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Jean-Baptiste Mardelle <jb.kdenlive@org> 0003 * SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include <QToolButton> 0009 #include <QWidget> 0010 0011 class MarkerListModel; 0012 class QMenu; 0013 0014 class MarkerCategoryButton : public QToolButton 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(bool allowAll READ allowAll WRITE setAllowAll NOTIFY changed) 0018 Q_PROPERTY(bool onlyUsed READ onlyUsed WRITE setOnlyUsed NOTIFY changed) 0019 0020 public: 0021 MarkerCategoryButton(QWidget *parent = nullptr); 0022 /** @brief Set currently selected category by its number. */ 0023 void setCurrentCategories(QList<int> categories); 0024 /** @brief get the number of the currently selected category. */ 0025 QList<int> currentCategories(); 0026 /** @brief Set the marker model of the chooser. Only needed if @property onlyUsed is true.*/ 0027 void setMarkerModel(const MarkerListModel *model); 0028 /** @brief Whether the user should be able to select "All Categories" */ 0029 void setAllowAll(bool allowAll); 0030 /** @brief Show only categories that are used by markers in the model. 0031 * If no model is set, all categories will be show. @see setMarkerModel 0032 */ 0033 void setOnlyUsed(bool onlyUsed); 0034 /** @brief Calling this will make the button checkable and have a default action on its own (for example enable/disable filtering) */ 0035 void enableFilterMode(); 0036 0037 private Q_SLOTS: 0038 void categorySelected(QAction *ac); 0039 0040 private: 0041 const MarkerListModel *m_markerListModel; 0042 bool m_allowAll; 0043 bool m_onlyUsed; 0044 QMenu *m_menu; 0045 0046 void refresh(); 0047 bool allowAll() { return m_allowAll; }; 0048 bool onlyUsed() { return m_onlyUsed; }; 0049 0050 Q_SIGNALS: 0051 void changed(); 0052 void categoriesChanged(const QList<int> categories); 0053 }; 0054