diff --git a/src/librssguard/gui/dialogs/formmain.cpp b/src/librssguard/gui/dialogs/formmain.cpp index 71a009842..bd3b4fcd1 100644 --- a/src/librssguard/gui/dialogs/formmain.cpp +++ b/src/librssguard/gui/dialogs/formmain.cpp @@ -178,6 +178,7 @@ QList FormMain::allActions() const { actions << m_ui->m_actionStopRunningItemsUpdate; actions << m_ui->m_actionEditSelectedItem; actions << m_ui->m_actionCopyUrlSelectedFeed; + actions << m_ui->m_actionCopyUrlSelectedArticles; actions << m_ui->m_actionDeleteSelectedItem; actions << m_ui->m_actionServiceAdd; actions << m_ui->m_actionServiceEdit; @@ -428,6 +429,7 @@ void FormMain::updateMessageButtonsAvailability() { m_ui->m_actionMarkSelectedMessagesAsUnread->setEnabled(atleast_one_message_selected); m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(atleast_one_message_selected); m_ui->m_actionOpenSelectedSourceArticlesExternally->setEnabled(atleast_one_message_selected); + m_ui->m_actionCopyUrlSelectedArticles->setEnabled(atleast_one_message_selected); m_ui->m_actionSendMessageViaEmail->setEnabled(one_message_selected); m_ui->m_actionSwitchImportanceOfSelectedMessages->setEnabled(atleast_one_message_selected); } @@ -543,6 +545,7 @@ void FormMain::setupIcons() { m_ui->m_actionDeleteSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-junk"))); m_ui->m_actionEditSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("document-edit"))); m_ui->m_actionCopyUrlSelectedFeed->setIcon(icon_theme_factory->fromTheme(QSL("edit-copy"))); + m_ui->m_actionCopyUrlSelectedArticles->setIcon(icon_theme_factory->fromTheme(QSL("edit-copy"))); m_ui->m_actionMarkAllItemsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read"))); m_ui->m_actionMarkSelectedItemsAsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read"))); m_ui->m_actionMarkSelectedItemsAsUnread->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread"))); @@ -789,6 +792,8 @@ void FormMain::createConnections() { &QAction::triggered, qApp->feedReader(), &FeedReader::stopRunningFeedUpdate); connect(m_ui->m_actionCopyUrlSelectedFeed, &QAction::triggered, tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::copyUrlOfSelectedFeeds); + connect(m_ui->m_actionCopyUrlSelectedArticles, + &QAction::triggered, tabWidget()->feedMessageViewer()->messagesView(), &MessagesView::copyUrlOfSelectedArticles); connect(m_ui->m_actionEditSelectedItem, &QAction::triggered, tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::editSelectedItem); connect(m_ui->m_actionViewSelectedItemsNewspaperMode, diff --git a/src/librssguard/gui/dialogs/formmain.ui b/src/librssguard/gui/dialogs/formmain.ui index 9d692892f..95e628bc7 100644 --- a/src/librssguard/gui/dialogs/formmain.ui +++ b/src/librssguard/gui/dialogs/formmain.ui @@ -45,7 +45,7 @@ 0 0 1296 - 21 + 22 @@ -148,6 +148,7 @@ + @@ -775,7 +776,7 @@ - &Copy URLs of selected item + &Copy URL of selected item @@ -841,6 +842,11 @@ Close &current tab + + + &Copy URLs of selected articles + + diff --git a/src/librssguard/gui/messagesview.cpp b/src/librssguard/gui/messagesview.cpp index cfe0ff13d..1aa2a8a8a 100644 --- a/src/librssguard/gui/messagesview.cpp +++ b/src/librssguard/gui/messagesview.cpp @@ -5,6 +5,7 @@ #include "3rd-party/boolinq/boolinq.h" #include "core/messagesmodel.h" #include "core/messagesproxymodel.h" +#include "definitions/definitions.h" #include "gui/dialogs/formmain.h" #include "gui/messagebox.h" #include "gui/reusable/labelsmenu.h" @@ -15,9 +16,11 @@ #include "miscellaneous/settings.h" #include "network-web/networkfactory.h" #include "network-web/webfactory.h" +#include "qnamespace.h" #include "services/abstract/labelsnode.h" #include "services/abstract/serviceroot.h" +#include #include #include #include @@ -110,6 +113,26 @@ void MessagesView::restoreHeaderState(const QByteArray& dta) { } } +void MessagesView::copyUrlOfSelectedArticles() const { + const QModelIndexList selected_indexes = selectionModel()->selectedRows(); + + if (selected_indexes.isEmpty()) { + return; + } + + const QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes); + QStringList urls; + + for (const auto article_idx : mapped_indexes) { + urls << m_sourceModel->data(m_sourceModel->index(article_idx.row(), MSG_DB_URL_INDEX), + Qt::ItemDataRole::EditRole).toString(); + } + + if (qApp->clipboard() != nullptr && !urls.isEmpty()) { + qApp->clipboard()->setText(urls.join(TextFactory::newline())); + } +} + void MessagesView::sort(int column, Qt::SortOrder order, bool repopulate_data, bool change_header, bool emit_changed_from_header, @@ -346,6 +369,7 @@ void MessagesView::initializeContextMenu() { << qApp->mainForm()->m_ui->m_actionSendMessageViaEmail << qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally << qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally + << qApp->mainForm()->m_ui->m_actionCopyUrlSelectedArticles << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread << qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages diff --git a/src/librssguard/gui/messagesview.h b/src/librssguard/gui/messagesview.h index 10e4c54a9..bb9529e28 100644 --- a/src/librssguard/gui/messagesview.h +++ b/src/librssguard/gui/messagesview.h @@ -28,6 +28,8 @@ class MessagesView : public BaseTreeView { void restoreHeaderState(const QByteArray& dta); public slots: + void copyUrlOfSelectedArticles() const; + void keyboardSearch(const QString& search); // Called after data got changed externally