Skip to content

Commit

Permalink
feat: add copy tags context menu to image previews (fix #2845)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Dec 14, 2022
1 parent 299749b commit ad0919c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/gui/src/image-context-menu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "image-context-menu.h"
#include <QApplication>
#include <QClipboard>
#include <QDesktopServices>
#include <QSignalMapper>
#include "functions.h"
Expand All @@ -15,6 +17,10 @@ ImageContextMenu::ImageContextMenu(QSettings *settings, QSharedPointer<Image> im
ReverseSearchLoader loader(m_settings);
m_reverseSearchEngines = loader.getAllReverseSearchEngines();

// Copy
addAction(QIcon(":/images/icons/copy.png"), tr("Copy all tags"), this, SLOT(copyAllTagsToClipboard()));
addSeparator();

// Open image in browser
addAction(QIcon(":/images/icons/browser.png"), tr("Open in browser"), this, SLOT(openInBrowser()), getKeySequence(m_settings, "Viewer/Shortcuts/keyOpenInBrowser"));

Expand All @@ -34,6 +40,11 @@ ImageContextMenu::ImageContextMenu(QSettings *settings, QSharedPointer<Image> im
}


void ImageContextMenu::copyAllTagsToClipboard()
{
QApplication::clipboard()->setText(m_image->tagsString().join(' '));
}

void ImageContextMenu::openInBrowser()
{
QDesktopServices::openUrl(m_image->pageUrl());
Expand Down
1 change: 1 addition & 0 deletions src/gui/src/image-context-menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ImageContextMenu : public QMenu
ImageContextMenu(QSettings *settings, QSharedPointer<Image> img, MainWindow *mw, QWidget *parent = nullptr);

protected slots:
void copyAllTagsToClipboard();
void openInBrowser();
void searchMd5();
void reverseImageSearch(int i);
Expand Down

0 comments on commit ad0919c

Please sign in to comment.