File indexing completed on 2024-05-12 15:59:58
0001 /* 0002 * This file is part of the KDE project 0003 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org> 0004 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net> 0005 * SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com> 0006 * SPDX-FileCopyrightText: 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com> 0007 * SPDX-FileCopyrightText: 2011 José Luis Vergara <pentalis@gmail.com> 0008 * SPDX-FileCopyrightText: 2013 Sascha Suelzer <s.suelzer@gmail.com> 0009 * SPDX-FileCopyrightText: 2020 Agata Cacko <cacko.azh@gmail.com> 0010 * 0011 * SPDX-License-Identifier: LGPL-2.0-or-later 0012 */ 0013 0014 #ifndef KISTAGTOOLBUTTON_H 0015 #define KISTAGTOOLBUTTON_H 0016 0017 #include <QWidget> 0018 #include <KisTag.h> 0019 0020 class KisTagModel; 0021 0022 #include <KoResource.h> 0023 0024 /** 0025 * \brief The KisTagToolButton class manages the logic of the tag management popup. 0026 * 0027 * This class is responsible for the GUI for creating, renaming and removing tags. 0028 * Since both renaming and removing is context-dependent (it depends on which tag 0029 * is currently selected in the combobox), all actions emit signals to the TagChooserWidget 0030 * for it to handle actual creating, renaming and removal of tags in the KisTagModel. 0031 */ 0032 class KisTagToolButton : public QWidget 0033 { 0034 Q_OBJECT 0035 0036 private: 0037 explicit KisTagToolButton(QWidget* parent = 0); 0038 ~KisTagToolButton() override; 0039 0040 /// 0041 /// \brief readOnlyMode sets the mode of the popup 0042 /// 0043 /// If the mode is read-only, then renaming and removal of the tag 0044 /// is not accessible (the textbox and the buttons are hidden). 0045 /// \param activate if true, then the popup is in the read-only mode. 0046 /// 0047 void readOnlyMode(bool activate); 0048 0049 /// 0050 /// \brief setUndeletionCandidate sets a new item in the deleted tags list 0051 /// 0052 /// Tags are never deleted fully, they are only marked inactive. 0053 /// Undeletion means marking them as active again. This function 0054 /// adds new tags for the user to be able to undelete them (mark active in the database). 0055 /// \param deletedTag tag that can be undeleted (activated again) 0056 /// 0057 void setUndeletionCandidate(const KisTagSP deletedTag); 0058 KisTagSP undeletionCandidate() const; 0059 0060 void setCurrentTag(const KisTagSP tag); 0061 0062 /// 0063 /// \brief updates icon file when loading and changing themes 0064 /// 0065 void loadIcon(); 0066 0067 Q_SIGNALS: 0068 /// 0069 /// \brief newTagRequested signals to the KisTagChooserWidget to create a new tag 0070 /// \param tag tag name written by the user (other fields are not used) 0071 /// 0072 /// Since KisTagToolButton doesn't know which KisTagModel it should be using (because it doesn't 0073 /// know the resourceType) and for the consistency, it signals KisTagChooserWidget to create 0074 /// a new tag with the name written by the user. 0075 void newTagRequested(const QString &tagName); 0076 0077 /// 0078 /// \brief renamingOfCurrentTagRequested signals to KisTagChooserWidget to rename the current tag 0079 /// \param tag tag name written by the user (other fields are not used) 0080 /// 0081 /// Since KisTagToolButton doesn't know which tag is current or which KisTagModel it should be using, 0082 /// it signals KisTagChooserWidget to do rename the current tag to the name written by the user. 0083 void renamingOfCurrentTagRequested(const QString &tagName); 0084 0085 /// 0086 /// \brief deletionOfCurrentTagRequested signals to KisTagChooserWidget to delete the current tag 0087 /// 0088 /// Since KisTagToolButton doesn't know which tag is current or which KisTagModel it should be using, 0089 /// it signals KisTagChooserWidget to do remove the current tag. 0090 void deletionOfCurrentTagRequested(); 0091 0092 /// 0093 /// \brief undeletionOfTagRequested signals to KisTagChooserWidget to undelete the mentioned tag 0094 /// \param tag tag to be undeleted (marked active again) 0095 /// 0096 /// Tags are never deleted fully, they are only marked inactive. 0097 /// Undeletion means marking them as active again. This function signals to KisTagChooserWidget 0098 /// that a tag mentioned in the argument should be activated. 0099 void undeletionOfTagRequested(const KisTagSP tag); 0100 /// 0101 /// \brief popupMenuAboutToShow signals that the tags popup will be shown soon. 0102 /// 0103 /// It is used by \see KisTagChooserWidget 0104 /// 0105 void popupMenuAboutToShow(); 0106 0107 private Q_SLOTS: 0108 /// 0109 /// \brief onTagUndeleteClicked is called when the user 0110 /// 0111 void onTagUndeleteClicked(); 0112 0113 private: 0114 class Private; 0115 Private* const d; 0116 friend class KisTagChooserWidget; 0117 }; 0118 0119 #endif // KOTAGTOOLBUTTON_H