Krita Source Code Documentation
Loading...
Searching...
No Matches
KisTagToolButton Class Reference

The KisTagToolButton class manages the logic of the tag management popup. More...

#include <KisTagToolButton.h>

+ Inheritance diagram for KisTagToolButton:

Classes

class  Private
 

Signals

void deletionOfCurrentTagRequested ()
 deletionOfCurrentTagRequested signals to KisTagChooserWidget to delete the current tag
 
void newTagRequested (const QString &tagName)
 newTagRequested signals to the KisTagChooserWidget to create a new tag
 
void popupMenuAboutToShow ()
 popupMenuAboutToShow signals that the tags popup will be shown soon.
 
void renamingOfCurrentTagRequested (const QString &tagName)
 renamingOfCurrentTagRequested signals to KisTagChooserWidget to rename the current tag
 
void undeletionOfTagRequested (const KisTagSP tag)
 undeletionOfTagRequested signals to KisTagChooserWidget to undelete the mentioned tag
 

Private Slots

void onTagUndeleteClicked ()
 onTagUndeleteClicked is called when the user
 

Private Member Functions

 KisTagToolButton (QWidget *parent=0)
 
void loadIcon ()
 updates icon file when loading and changing themes
 
void readOnlyMode (bool activate)
 readOnlyMode sets the mode of the popup
 
void setCurrentTag (const KisTagSP tag)
 
void setUndeletionCandidate (const KisTagSP deletedTag)
 setUndeletionCandidate sets a new item in the deleted tags list
 
KisTagSP undeletionCandidate () const
 
 ~KisTagToolButton () override
 

Private Attributes

Private *const d
 

Friends

class KisTagChooserWidget
 

Detailed Description

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-dependent (it depends on which tag is currently selected in the combobox), all actions Q_EMIT signals to the TagChooserWidget for it to handle actual creating, renaming and removal of tags in the KisTagModel.

Definition at line 32 of file KisTagToolButton.h.

Constructor & Destructor Documentation

◆ KisTagToolButton()

KisTagToolButton::KisTagToolButton ( QWidget * parent = 0)
explicitprivate

Definition at line 44 of file KisTagToolButton.cpp.

45 : QWidget(parent)
46 , d(new Private())
47{
48 QGridLayout* buttonLayout = new QGridLayout(this);
49 buttonLayout->setContentsMargins(0, 0, 0, 0);
50 buttonLayout->setSpacing(0);
51
52 d->tagToolButton = new QToolButton(this);
53 loadIcon();
54 d->tagToolButton->setText(i18n("Tag"));
55 d->tagToolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
56 d->tagToolButton->setToolTip(i18nc("@info:tooltip", "<qt>Show the tag box options.</qt>"));
57 d->tagToolButton->setPopupMode(QToolButton::InstantPopup);
58 d->tagToolButton->setEnabled(true);
59
60 QMenu* popup = new QMenu(this);
61
62 KisMenuStyleDontCloseOnAlt *menuStyle = new KisMenuStyleDontCloseOnAlt(popup->style());
63 menuStyle->setParent(popup);
64 popup->setStyle(menuStyle);
65
66 d->addTagAction = new UserInputTagAction(popup);
67 d->addTagAction->setPlaceholderText(i18n("New tag"));
68 d->addTagAction->setIcon(koIcon("document-new"));
70 popup->addAction(d->addTagAction);
71
72 connect(d->addTagAction, SIGNAL(triggered(QString)), this, SIGNAL(newTagRequested(QString)));
73
75 d->renameTagAction->setPlaceholderText(i18n("Rename tag"));
76 d->renameTagAction->setIcon(koIcon("edit-rename"));
78 popup->addAction(d->renameTagAction);
79
80 connect(d->renameTagAction, SIGNAL(triggered(QString)), this, SIGNAL(renamingOfCurrentTagRequested(QString)));
81
82 popup->addSeparator();
83
84 d->deleteTagAction = new QAction(popup);
85 d->deleteTagAction->setText(i18n("Delete this tag"));
86 d->deleteTagAction->setIcon(koIcon("edit-delete"));
87 popup->addAction(d->deleteTagAction);
88
89 connect(d->deleteTagAction, SIGNAL(triggered()), this, SIGNAL(deletionOfCurrentTagRequested()));
90
91 popup->addSeparator();
92
93 d->undeleteTagAction = new QAction(popup);
94 d->undeleteTagAction->setIcon(koIcon("edit-redo"));
95 d->undeleteTagAction->setVisible(false);
96 popup->addAction(d->undeleteTagAction);
97
98 connect(d->undeleteTagAction, SIGNAL(triggered()), this, SLOT(onTagUndeleteClicked()));
99
100 connect(popup, SIGNAL(aboutToShow()), this, SIGNAL(popupMenuAboutToShow()));
101
102 d->tagToolButton->setMenu(popup);
103 buttonLayout->addWidget(d->tagToolButton);
104}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
UserInputTagAction * addTagAction
UserInputTagAction * renameTagAction
void popupMenuAboutToShow()
popupMenuAboutToShow signals that the tags popup will be shown soon.
void deletionOfCurrentTagRequested()
deletionOfCurrentTagRequested signals to KisTagChooserWidget to delete the current tag
void newTagRequested(const QString &tagName)
newTagRequested signals to the KisTagChooserWidget to create a new tag
void renamingOfCurrentTagRequested(const QString &tagName)
renamingOfCurrentTagRequested signals to KisTagChooserWidget to rename the current tag
void onTagUndeleteClicked()
onTagUndeleteClicked is called when the user
void loadIcon()
updates icon file when loading and changing themes
void setPlaceholderText(const QString &clickMessage)
void setIcon(const QIcon &icon)
void setCloseParentOnTrigger(bool closeParent)
The UserInputTagAction class defines an action with user text input that sends a signal with a simple...
Definition TagActions.h:131
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25

References KisTagToolButton::Private::addTagAction, connect(), d, KisTagToolButton::Private::deleteTagAction, deletionOfCurrentTagRequested(), koIcon, loadIcon(), newTagRequested(), onTagUndeleteClicked(), popupMenuAboutToShow(), KisTagToolButton::Private::renameTagAction, renamingOfCurrentTagRequested(), LineEditAction::setCloseParentOnTrigger(), LineEditAction::setIcon(), LineEditAction::setPlaceholderText(), KisTagToolButton::Private::tagToolButton, and KisTagToolButton::Private::undeleteTagAction.

◆ ~KisTagToolButton()

KisTagToolButton::~KisTagToolButton ( )
overrideprivate

Definition at line 106 of file KisTagToolButton.cpp.

107{
108 delete d;
109}

References d.

Member Function Documentation

◆ deletionOfCurrentTagRequested

void KisTagToolButton::deletionOfCurrentTagRequested ( )
signal

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.

◆ loadIcon()

void KisTagToolButton::loadIcon ( )
private

updates icon file when loading and changing themes

Definition at line 141 of file KisTagToolButton.cpp.

142{
143 d->tagToolButton->setIcon(koIcon("bookmarks"));
144}

References d, koIcon, and KisTagToolButton::Private::tagToolButton.

◆ newTagRequested

void KisTagToolButton::newTagRequested ( const QString & tagName)
signal

newTagRequested signals to the KisTagChooserWidget to create a new tag

Parameters
tagtag 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.

◆ onTagUndeleteClicked

void KisTagToolButton::onTagUndeleteClicked ( )
privateslot

onTagUndeleteClicked is called when the user

Definition at line 146 of file KisTagToolButton.cpp.

147{
149}
void undeletionOfTagRequested(const KisTagSP tag)
undeletionOfTagRequested signals to KisTagChooserWidget to undelete the mentioned tag

References d, KisTagToolButton::Private::undeleteCandidate, and undeletionOfTagRequested().

◆ popupMenuAboutToShow

void KisTagToolButton::popupMenuAboutToShow ( )
signal

popupMenuAboutToShow signals that the tags popup will be shown soon.

It is used by

See also
KisTagChooserWidget

◆ readOnlyMode()

void KisTagToolButton::readOnlyMode ( bool activate)
private

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).

Parameters
activateif true, then the popup is in the read-only mode.

Definition at line 111 of file KisTagToolButton.cpp.

112{
113 activate = !activate;
114 d->renameTagAction->setVisible(activate);
115 d->deleteTagAction->setVisible(activate);
116}
void setVisible(bool showAction)

References d, KisTagToolButton::Private::deleteTagAction, KisTagToolButton::Private::renameTagAction, and LineEditAction::setVisible().

◆ renamingOfCurrentTagRequested

void KisTagToolButton::renamingOfCurrentTagRequested ( const QString & tagName)
signal

renamingOfCurrentTagRequested signals to KisTagChooserWidget to rename the current tag

Parameters
tagtag 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.

◆ setCurrentTag()

void KisTagToolButton::setCurrentTag ( const KisTagSP tag)
private

Definition at line 135 of file KisTagToolButton.cpp.

136{
137 d->currentTag = tag;
138 d->deleteTagAction->setProperty("currentTag", QVariant::fromValue<KisTagSP>(tag));
139}

References KisTagToolButton::Private::currentTag, d, and KisTagToolButton::Private::deleteTagAction.

◆ setUndeletionCandidate()

void KisTagToolButton::setUndeletionCandidate ( const KisTagSP deletedTag)
private

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).

Parameters
deletedTagtag that can be undeleted (activated again)

Definition at line 118 of file KisTagToolButton.cpp.

119{
120 if (deletedTag.isNull() || deletedTag->name().isEmpty()) {
121 d->undeleteTagAction->setVisible(false);
122 d->undeleteCandidate.clear();
123 } else {
124 d->undeleteCandidate = deletedTag;
125 d->undeleteTagAction->setText(i18n("Undelete") +" "+ deletedTag->name());
126 d->undeleteTagAction->setVisible(true);
127 }
128}

References d, KisTagToolButton::Private::undeleteCandidate, and KisTagToolButton::Private::undeleteTagAction.

◆ undeletionCandidate()

KisTagSP KisTagToolButton::undeletionCandidate ( ) const
private

Definition at line 130 of file KisTagToolButton.cpp.

131{
132 return d->undeleteCandidate;
133}

References d, and KisTagToolButton::Private::undeleteCandidate.

◆ undeletionOfTagRequested

void KisTagToolButton::undeletionOfTagRequested ( const KisTagSP tag)
signal

undeletionOfTagRequested signals to KisTagChooserWidget to undelete the mentioned tag

Parameters
tagtag 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.

Friends And Related Symbol Documentation

◆ KisTagChooserWidget

friend class KisTagChooserWidget
friend

Definition at line 116 of file KisTagToolButton.h.

Member Data Documentation

◆ d

Private* const KisTagToolButton::d
private

Definition at line 115 of file KisTagToolButton.h.


The documentation for this class was generated from the following files: