File indexing completed on 2024-05-12 15:59:57
0001 /* 0002 * This file is part of the KDE project 0003 * SPDX-FileCopyrightText: 2013 Sascha Suelzer <s.suelzer@gmail.com> 0004 * SPDX-FileCopyrightText: 2019 Boudewijn Rempt <boud@valdyas.org> 0005 * SPDX-FileCopyrightText: 2020 Agata Cacko <cacko.azh@gmail.com> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 * */ 0009 0010 #ifndef KISRESOURCEITEMCHOOSERCONTEXTMENU_H 0011 #define KISRESOURCEITEMCHOOSERCONTEXTMENU_H 0012 0013 #include <QMenu> 0014 #include <QWidgetAction> 0015 #include <QLabel> 0016 #include <QLineEdit> 0017 0018 #include <KoResource.h> 0019 #include <KisTag.h> 0020 #include <KisTagModel.h> 0021 0022 #include "TagActions.h" 0023 #include "KisTagChooserWidget.h" 0024 0025 /// 0026 /// \brief The KisResourceItemChooserContextMenu class is responsible for the context menu in ResourceItemChooser 0027 /// 0028 /// The context menu for the resource item in the resource item chooser (see: main area in the Brush Presets docker) 0029 /// contains actions to tag and untag the selected resource. 0030 /// In case of tagging the user can choose to create a new tag or select one of the existing ones. 0031 /// In case of untagging the user can untag from the current selected tag (in the combobox) or from some other tags. 0032 /// This class needs to provide correct lists of tags and take into account that "All" and "All Untagged" (and possibly other 0033 /// generated tags) are special and the user cannot untage the resource from it. 0034 /// 0035 class KisResourceItemChooserContextMenu : public QMenu 0036 { 0037 Q_OBJECT 0038 public: 0039 /// 0040 /// \brief KisResourceItemChooserContextMenu the constructor for the KisResourceItemChooserContextMenu class 0041 /// \param resource the resource that the context menu is called for 0042 /// \param currentlySelectedTag the currently selected tag in the combobox over the resource item chooser 0043 /// 0044 explicit KisResourceItemChooserContextMenu(KoResourceSP resource, const KisTagSP currentlySelectedTag, KisTagChooserWidget *tagChooser); 0045 /// \brief the destructor 0046 ~KisResourceItemChooserContextMenu() override; 0047 0048 Q_SIGNALS: 0049 0050 /// Emitted when a resource should be added to an existing tag. 0051 void resourceTagAdditionRequested(const KisTagSP tag, KoResourceSP resource); 0052 0053 /// Emitted when a resource should be removed from an existing tag. 0054 void resourceTagRemovalRequested(KoResourceSP resource, const KisTagSP tag); 0055 0056 /// Emitted when a resource should be added to a new tag, which will need to be created. 0057 void resourceAssignmentToNewTagRequested(const QString &tag, KoResourceSP resource); 0058 0059 0060 public Q_SLOTS: 0061 0062 /// 0063 /// \brief removeResourceExistingTag slot for a signal from the action to remove the tag from the resource 0064 /// \param resource resource that the tag needs to be removed from 0065 /// \param tag tag that needs to be removed from the resource 0066 /// 0067 void removeResourceExistingTag(const KisTagSP tag, KoResourceSP resource); 0068 0069 /// 0070 /// \brief addResourceExistingTag slot for a signal from the action to add the tag to the resource 0071 /// \param resource resource that the tag needs to be add to 0072 /// \param tag tag that needs to be add to the resource 0073 /// 0074 void addResourceExistingTag(const KisTagSP tag, KoResourceSP resource); 0075 0076 0077 private: 0078 /// 0079 /// \brief m_tagModel data model for tags (for tagging and untagging resources and create lists of tags) 0080 /// 0081 KisTagModel *m_tagModel {0}; 0082 KisTagChooserWidget *m_tagChooserWidget {0}; 0083 0084 }; 0085 0086 #endif // KORESOURCEITEMCHOOSERCONTEXTMENU_H