diff --git a/libs/resourcewidgets/KisTagChooserWidget.h b/libs/resourcewidgets/KisTagChooserWidget.h index e8c0c6d4d9..e7f5cefa71 100644 --- a/libs/resourcewidgets/KisTagChooserWidget.h +++ b/libs/resourcewidgets/KisTagChooserWidget.h @@ -1,108 +1,108 @@ /* * This file is part of the KDE project * Copyright (c) 2002 Patrick Julien * Copyright (c) 2007 Jan Hambrecht * Copyright (c) 2007 Sven Langkamp * Copyright (C) 2011 Srikanth Tiyyagura * Copyright (c) 2011 José Luis Vergara * Copyright (c) 2013 Sascha Suelzer * Copyright (c) 2019 Boudewijn Rempt * Copyright (c) 2020 Agata Cacko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISTAGCHOOSERWIDGET_H #define KISTAGCHOOSERWIDGET_H #include #include "kritaresourcewidgets_export.h" #include #include /// /// \brief The KisTagChooserWidget class is responsible /// /// for all the logic that tags combobox has in various resource choosers. /// (Example of usage: tag combobox in Brushes docker). /// It uses KisTagModel as a model for items in the combobox. /// It is also responsible for the popup for tag removal, renaming and creation -/// that appears on the right side of the tag combobox. +/// that appears on the right side of the tag combobox (via KisTagToolButton) /// All the logic for adding and removing tags is done through KisTagModel. /// /// For logic related to tagging and untagging resources, check KisTaggingManager /// and KisItemChooserContextMenu. /// class KRITARESOURCEWIDGETS_EXPORT KisTagChooserWidget : public QWidget { Q_OBJECT public: explicit KisTagChooserWidget(KisTagModel* model, QWidget* parent); ~KisTagChooserWidget() override; /// \brief setCurrentIndex sets the current index in the combobox /// \param index index is the /// void setCurrentIndex(int index); int currentIndex() const; /// \brief currentlySelectedTag returns the current tag from combobox /// \return the tag that is currently selected in the tag combobox /// KisTagSP currentlySelectedTag(); /// /// \brief selectedTagIsReadOnly checks whether the tag is readonly (generated by Krita) /// \return true if the tag was generated by Krita, false if it's just a normal tag /// bool selectedTagIsReadOnly(); void addItems(QList tagNames); void addReadOnlyItem(KisTagSP tagName); void clear(); void setUndeletionCandidate(const KisTagSP tag); void showTagToolButton(bool show); Q_SIGNALS: void newTagRequested(const KisTagSP tag); void tagDeletionRequested(const KisTagSP tag); void tagRenamingRequested(const KisTagSP oldTag, const KisTagSP newTag); void tagUndeletionRequested(const KisTagSP tag); void tagUndeletionListPurgeRequested(); void popupMenuAboutToShow(); void tagChosen(const KisTagSP tag); public Q_SLOTS: KisTagSP insertItem(KisTagSP tag); void tagChanged(int index); private Q_SLOTS: void tagRenamingRequested(const KisTagSP newName); void tagOptionsContextMenuAboutToShow(); void contextDeleteCurrentTag(); private: class Private; Private* const d; }; ; #endif // KOTAGCHOOSERWIDGET_H diff --git a/libs/resourcewidgets/KisTagToolButton.h b/libs/resourcewidgets/KisTagToolButton.h index 5dc7e8f114..6191536cee 100644 --- a/libs/resourcewidgets/KisTagToolButton.h +++ b/libs/resourcewidgets/KisTagToolButton.h @@ -1,61 +1,109 @@ /* * This file is part of the KDE project * Copyright (c) 2002 Patrick Julien * Copyright (c) 2007 Jan Hambrecht * Copyright (c) 2007 Sven Langkamp * Copyright (C) 2011 Srikanth Tiyyagura * Copyright (c) 2011 José Luis Vergara * Copyright (c) 2013 Sascha Suelzer * Copyright (c) 2020 Agata Cacko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISTAGTOOLBUTTON_H #define KISTAGTOOLBUTTON_H #include #include - +/// +/// \brief The KisTagToolButton class manages the logic of the tag management popup. +/// +/// This class is responsible for the GUI for creating, renaming and removing tags. +/// Since both renaming and removing is context-dependant (it depends on which tag +/// is currently selected in the combobox), all actions emit signals to the TagChooserWidget +/// for it to handle actual creationg, renaming and removal of tags in the KisTagModel. +/// class KisTagToolButton : public QWidget { Q_OBJECT private: explicit KisTagToolButton(QWidget* parent = 0); ~KisTagToolButton() override; + + /// + /// \brief readOnlyMode sets the mode of the popup + /// + /// If the mode is read-only, then renaming and removal of the tag + /// is not accessible (the textbox and the buttons are hidden). + /// \param activate if true, then the popup is in the read-only mode. + /// void readOnlyMode(bool activate); + /// + /// \brief setUndeletionCandidate sets a new item in the deleted tags list + /// + /// Tags are never deleted fully, they are only marked inactive. + /// Undeletion means marking them as active again. This function + /// adds new tags for the user to be able to undelete them (mark active in the database). + /// \param deletedTag tag that can be undeleted (activated again) + /// void setUndeletionCandidate(const KisTagSP deletedTag); Q_SIGNALS: + /// + /// \brief newTagRequested signals to the KisTagChooserWidget to create a new tag + /// \param tag tag name written by the user (other fields are not used) + /// + /// Since KisTagToolButton doesn't know which KisTagModel it should be using (because it doesn't + /// know the resourceType) and for the consistency, it signals KisTagChooserWidget to create + /// a new tag with the name written by the user. void newTagRequested(const KisTagSP tag); + /// + /// \brief renamingOfCurrentTagRequested signals to KisTagChooserWidget to rename the current tag + /// \param tag tag name written by the user (other fields are not used) + /// + /// Since KisTagToolButton doesn't know which tag is current or which KisTagModel it should be using, + /// it signals KisTagChooserWidget to do rename the current tag to the name written by the user. void renamingOfCurrentTagRequested(const KisTagSP tag); + /// + /// \brief deletionOfCurrentTagRequested signals to KisTagChooserWidget to delete the current tag + /// + /// Since KisTagToolButton doesn't know which tag is current or which KisTagModel it should be using, + /// it signals KisTagChooserWidget to do remove the current tag. void deletionOfCurrentTagRequested(); + /// + /// \brief undeletionOfTagRequested signals to KisTagChooserWidget to undelete the mentioned tag + /// \param tag tag to be undeleted (marked active again) + /// + /// Tags are never deleted fully, they are only marked inactive. + /// Undeletion means marking them as active again. This function signals to KisTagChooserWidget + /// that a tag mentioned in the argument should be activated. void undeletionOfTagRequested(const KisTagSP tag); void purgingOfTagUndeleteListRequested(); void popupMenuAboutToShow(); private Q_SLOTS: void onTagUndeleteClicked(); private: class Private; Private* const d; friend class KisTagChooserWidget; }; #endif // KOTAGTOOLBUTTON_H