| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2010-09-12 |
| 7 |
* Description : Widget for assignment and confirmation of names for faces |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2010 by Aditya Bhatt <adityabhatt1991 at gmail dot com> |
| 10 |
* SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> |
| 11 |
* SPDX-FileCopyrightText: 2012-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 12 |
* |
| 13 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 14 |
* |
| 15 |
* ============================================================ */ |
| 16 |
|
| 17 |
#pragma once |
| 18 |
|
| 19 |
// Qt includes |
| 20 |
|
| 21 |
#include <QFrame> |
| 22 |
#include <QVariant> |
| 23 |
|
| 24 |
namespace Digikam |
| 25 |
{ |
| 26 |
|
| 27 |
class AddTagsComboBox; |
| 28 |
class AddTagsLineEdit; |
| 29 |
class CheckableAlbumFilterModel; |
| 30 |
class FaceTagsIface; |
| 31 |
class ItemInfo; |
| 32 |
class TAlbum; |
| 33 |
class TaggingAction; |
| 34 |
class TagModel; |
| 35 |
class TagPropertiesFilterModel; |
| 36 |
|
| 37 |
class AssignNameWidget : public QFrame |
| 38 |
{ |
| 39 |
Q_OBJECT |
| 40 |
Q_PROPERTY(Mode mode READ mode WRITE setMode) |
| 41 |
Q_PROPERTY(TagEntryWidgetMode tagEntryWidgetMode READ tagEntryWidgetMode WRITE setTagEntryWidgetMode) |
| 42 |
Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode) |
| 43 |
Q_PROPERTY(VisualStyle visualStyle READ visualStyle WRITE setVisualStyle) |
| 44 |
|
| 45 |
public: |
| 46 |
|
| 47 |
enum Mode |
| 48 |
{ |
| 49 |
InvalidMode, |
| 50 |
UnconfirmedEditMode, |
| 51 |
ConfirmedMode, |
| 52 |
ConfirmedEditMode, |
| 53 |
IgnoredMode |
| 54 |
}; |
| 55 |
Q_ENUM(Mode) |
| 56 |
|
| 57 |
enum TagEntryWidgetMode |
| 58 |
{ |
| 59 |
InvalidTagEntryWidgetMode, |
| 60 |
AddTagsComboBoxMode, |
| 61 |
AddTagsLineEditMode |
| 62 |
}; |
| 63 |
Q_ENUM(TagEntryWidgetMode) |
| 64 |
|
| 65 |
enum LayoutMode |
| 66 |
{ |
| 67 |
InvalidLayout, |
| 68 |
FullLine, |
| 69 |
TwoLines, |
| 70 |
Compact |
| 71 |
}; |
| 72 |
Q_ENUM(LayoutMode) |
| 73 |
|
| 74 |
enum VisualStyle |
| 75 |
{ |
| 76 |
InvalidVisualStyle, |
| 77 |
StyledFrame, |
| 78 |
TranslucentDarkRound, |
| 79 |
TranslucentThemedFrameless |
| 80 |
}; |
| 81 |
Q_ENUM(VisualStyle) |
| 82 |
|
| 83 |
public: |
| 84 |
|
| 85 |
/** |
| 86 |
* Please take care: you must set all four modes before usage! |
| 87 |
*/ |
| 88 |
explicit AssignNameWidget(QWidget* const parent = nullptr); |
| 89 |
~AssignNameWidget() override; |
| 90 |
|
| 91 |
/** |
| 92 |
* Set the tag model to use for completion. |
| 93 |
*/ |
| 94 |
void setAlbumModels(TagModel* const model, |
| 95 |
TagPropertiesFilterModel* const filteredModel, |
| 96 |
CheckableAlbumFilterModel* const filterModel); |
| 97 |
void setDefaultModel(); |
| 98 |
|
| 99 |
void setMode(Mode mode); |
| 100 |
Mode mode() const; |
| 101 |
|
| 102 |
void setTagEntryWidgetMode(TagEntryWidgetMode mode); |
| 103 |
TagEntryWidgetMode tagEntryWidgetMode() const; |
| 104 |
|
| 105 |
void setLayoutMode(LayoutMode mode); |
| 106 |
LayoutMode layoutMode() const; |
| 107 |
|
| 108 |
void setVisualStyle(VisualStyle style); |
| 109 |
VisualStyle visualStyle() const; |
| 110 |
|
| 111 |
ItemInfo info() const; |
| 112 |
QVariant faceIdentifier() const; |
| 113 |
|
| 114 |
/** |
| 115 |
* The combo box or line edit in use, if any. |
| 116 |
*/ |
| 117 |
AddTagsComboBox* comboBox() const; |
| 118 |
AddTagsLineEdit* lineEdit() const; |
| 119 |
|
| 120 |
public Q_SLOTS: |
| 121 |
|
| 122 |
/** |
| 123 |
* The identifying information emitted with the signals. |
| 124 |
*/ |
| 125 |
void setUserData(const ItemInfo& info, const QVariant& faceIdentifier = QVariant()); |
| 126 |
|
| 127 |
/** |
| 128 |
* Sets the suggested (UnconfirmedEditMode) or assigned (ConfirmedMode) tag to be displayed. |
| 129 |
*/ |
| 130 |
void setCurrentTag(int tagId); |
| 131 |
void setCurrentTag(TAlbum* album); |
| 132 |
void setCurrentFace(const FaceTagsIface& face); |
| 133 |
|
| 134 |
/** |
| 135 |
* Set a parent tag for suggesting a parent tag for a new tag, and a default action. |
| 136 |
*/ |
| 137 |
void setParentTag(TAlbum* album); |
| 138 |
|
| 139 |
Q_SIGNALS: |
| 140 |
|
| 141 |
/** |
| 142 |
* A name has been assigned to the associated face. |
| 143 |
* This can be an existing tag, or a new tag, as described by TaggingAction. |
| 144 |
* For convenience, info() and faceIdentifier() are provided. |
| 145 |
*/ |
| 146 |
void assigned(const TaggingAction& action, const ItemInfo& info, const QVariant& faceIdentifier); |
| 147 |
|
| 148 |
/** |
| 149 |
* The suggestion has been rejected and the face will be moved to Unknown. |
| 150 |
* For convenience, info() and faceIdentifier() are provided. |
| 151 |
*/ |
| 152 |
void rejected(const ItemInfo& info, const QVariant& faceIdentifier); |
| 153 |
|
| 154 |
void ignored(const ItemInfo& info, const QVariant& faceIdentifier); |
| 155 |
|
| 156 |
/** |
| 157 |
* In IgnoredMode, this signal is emitted when the user clicked on the label. |
| 158 |
*/ |
| 159 |
void ignoredClicked(const ItemInfo& info, const QVariant& faceIdentifier); |
| 160 |
|
| 161 |
/** |
| 162 |
* In ConfirmedMode, this signal is emitted when the user clicked on the label. |
| 163 |
*/ |
| 164 |
void labelClicked(const ItemInfo& info, const QVariant& faceIdentifier); |
| 165 |
|
| 166 |
/** |
| 167 |
* An action has been selected. This purely signals user interaction, |
| 168 |
* no fixed decision - mouse hover may be enough to emit this signal. |
| 169 |
* The action may be invalid (user switched back to empty selection). |
| 170 |
*/ |
| 171 |
void selected(const TaggingAction& action, const ItemInfo& info, const QVariant& faceIdentifier); |
| 172 |
|
| 173 |
protected: |
| 174 |
|
| 175 |
void keyPressEvent(QKeyEvent* e) override; |
| 176 |
void showEvent(QShowEvent* e) override; |
| 177 |
|
| 178 |
protected Q_SLOTS: |
| 179 |
|
| 180 |
void slotConfirm(); |
| 181 |
void slotReject(); |
| 182 |
void slotIgnore(); |
| 183 |
void slotActionActivated(const TaggingAction& action); |
| 184 |
void slotActionSelected(const TaggingAction& action); |
| 185 |
void slotIgnoredClicked(); |
| 186 |
void slotLabelClicked(); |
| 187 |
|
| 188 |
private: |
| 189 |
|
| 190 |
class Private; |
| 191 |
Private* const d = nullptr; |
| 192 |
}; |
| 193 |
|
| 194 |
} // namespace Digikam |