diff --git a/src/gui/src/image-context-menu.cpp b/src/gui/src/image-context-menu.cpp index 3c6fde298..526117154 100644 --- a/src/gui/src/image-context-menu.cpp +++ b/src/gui/src/image-context-menu.cpp @@ -19,6 +19,7 @@ ImageContextMenu::ImageContextMenu(QSettings *settings, QSharedPointer im // Copy addAction(QIcon(":/images/icons/copy.png"), tr("Copy all tags"), this, SLOT(copyAllTagsToClipboard())); + addAction(QIcon(":/images/icons/copy.png"), tr("Copy all tags (with namespaces)"), this, SLOT(copyAllTagsWithNamespacesToClipboard())); addSeparator(); // Open image in browser @@ -45,6 +46,11 @@ void ImageContextMenu::copyAllTagsToClipboard() QApplication::clipboard()->setText(m_image->tagsString().join(' ')); } +void ImageContextMenu::copyAllTagsWithNamespacesToClipboard() +{ + QApplication::clipboard()->setText(m_image->tagsString(true).join(' ')); +} + void ImageContextMenu::openInBrowser() { QDesktopServices::openUrl(m_image->pageUrl()); diff --git a/src/gui/src/image-context-menu.h b/src/gui/src/image-context-menu.h index 00484b004..fd1993ab8 100644 --- a/src/gui/src/image-context-menu.h +++ b/src/gui/src/image-context-menu.h @@ -20,6 +20,7 @@ class ImageContextMenu : public QMenu protected slots: void copyAllTagsToClipboard(); + void copyAllTagsWithNamespacesToClipboard(); void openInBrowser(); void searchMd5(); void reverseImageSearch(int i); diff --git a/src/gui/src/tag-context-menu.cpp b/src/gui/src/tag-context-menu.cpp index 5c416379b..4036e07f9 100644 --- a/src/gui/src/tag-context-menu.cpp +++ b/src/gui/src/tag-context-menu.cpp @@ -54,6 +54,7 @@ TagContextMenu::TagContextMenu(QString tag, QList allTags, QUrl browserUrl, addAction(QIcon(":/images/icons/copy.png"), tr("Copy tag"), this, SLOT(copyTagToClipboard())); if (!allTags.isEmpty()) { addAction(QIcon(":/images/icons/copy.png"), tr("Copy all tags"), this, SLOT(copyAllTagsToClipboard())); + addAction(QIcon(":/images/icons/copy.png"), tr("Copy all tags (with namespaces)"), this, SLOT(copyAllTagsWithNamespacesToClipboard())); } addSeparator(); @@ -145,3 +146,14 @@ void TagContextMenu::copyAllTagsToClipboard() QApplication::clipboard()->setText(tags.join(' ')); } +void TagContextMenu::copyAllTagsWithNamespacesToClipboard() +{ + QStringList tags; + tags.reserve(m_allTags.count()); + for (const Tag &tag : qAsConst(m_allTags)) { + const QString nspace = !tag.type().isUnknown() ? tag.type().name() + ":" : QString(); + tags.append(nspace + tag.text()); + } + + QApplication::clipboard()->setText(tags.join(' ')); +} diff --git a/src/gui/src/tag-context-menu.h b/src/gui/src/tag-context-menu.h index 4bfe81128..133fdd01d 100644 --- a/src/gui/src/tag-context-menu.h +++ b/src/gui/src/tag-context-menu.h @@ -35,6 +35,7 @@ class TagContextMenu : public QMenu void openInBrowser(); void copyTagToClipboard(); void copyAllTagsToClipboard(); + void copyAllTagsWithNamespacesToClipboard(); signals: void setFavoriteImage(); diff --git a/src/lib/src/models/image.cpp b/src/lib/src/models/image.cpp index e883a4d49..df050ed75 100644 --- a/src/lib/src/models/image.cpp +++ b/src/lib/src/models/image.cpp @@ -932,12 +932,13 @@ Image::Size Image::preferredDisplaySize() const : Size::Full; } -QStringList Image::tagsString() const +QStringList Image::tagsString(bool namespaces) const { QStringList tags; tags.reserve(m_tags.count()); for (const Tag &tag : m_tags) { - tags.append(tag.text()); + const QString nspace = namespaces && !tag.type().isUnknown() ? tag.type().name() + ":" : QString(); + tags.append(nspace + tag.text()); } return tags; } diff --git a/src/lib/src/models/image.h b/src/lib/src/models/image.h index f7738ba3f..27c7e5fa5 100644 --- a/src/lib/src/models/image.h +++ b/src/lib/src/models/image.h @@ -51,7 +51,7 @@ class Image : public QObject, public Downloadable int value() const; QString md5() const; const QList &tags() const; - QStringList tagsString() const; + QStringList tagsString(bool namespaces = false) const; const QList &pools() const; qulonglong id() const; QVariantMap identity() const;