From a31a63bc46df07569bb05c69fb027d6edc0aee3d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Mar 2024 17:07:59 +0300 Subject: =?UTF-8?q?fixes=20#4305=20(NewStory:=20=D0=BF=D1=83=D0=BD=D0=BA?= =?UTF-8?q?=D1=82=20=D0=BC=D0=B5=D0=BD=D1=8E=20"=D0=BA=D0=BE=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D1=81=D1=8B=D0=BB?= =?UTF-8?q?=D0=BA=D1=83")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_array.cpp | 9 +++++++++ plugins/NewStory/src/history_array.h | 1 + plugins/NewStory/src/history_control.cpp | 8 ++++++-- plugins/NewStory/src/history_menus.cpp | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 6bc1d6e0d2..9a5185c905 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -353,6 +353,15 @@ void ItemData::getFontColor(int &fontId, int &colorId) const } } +const char* ItemData::getUrl() const +{ + if (auto el = m_doc->get_over_element()) + if (!mir_strcmp(el->get_tagName(), "a")) + return el->get_attr("href"); + + return nullptr; +} + void ItemData::load(bool bLoadAlways) { if (!bLoadAlways && m_bLoaded) diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 9a5e6f52d2..2fa212c0d6 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -45,6 +45,7 @@ struct ItemData int getTemplate() const; int getCopyTemplate() const; void getFontColor(int &fontId, int &colorId) const; + const char* getUrl() const; CMStringW formatHtml(const wchar_t *pwszStr = 0); CMStringW formatString() { return TplFormatString(getTemplate(), hContact, this); } diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 4c9b7fbb48..985f5d7fe3 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -309,8 +309,12 @@ void NewstoryListData::CopyPath() void NewstoryListData::CopyUrl() { - if (auto *pItem = GetItem(caret)) - Srmm_DownloadOfflineFile(pItem->hContact, pItem->dbe.getEvent(), OFD_COPYURL); + if (auto *pItem = GetItem(caret)) { + if (pItem->m_bOfflineFile) + Srmm_DownloadOfflineFile(pItem->hContact, pItem->dbe.getEvent(), OFD_COPYURL); + else if (auto *pszUrl = pItem->getUrl()) + Utils_ClipboardCopy(MClipAnsi(pszUrl)); + } } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/NewStory/src/history_menus.cpp b/plugins/NewStory/src/history_menus.cpp index 4fcb785562..ee30a0a569 100644 --- a/plugins/NewStory/src/history_menus.cpp +++ b/plugins/NewStory/src/history_menus.cpp @@ -58,6 +58,8 @@ HMENU NSMenu_Build(NewstoryListData *data, ItemData *item) Menu_ShowItem(hmiDownload, !item->m_bOfflineDownloaded && bNotProtected); Menu_ShowItem(hmiOpenFolder, item->m_bOfflineDownloaded); } + else if (mir_strlen(item->getUrl())) + Menu_ShowItem(hmiCopyUrl, true); bEditable = (item->dbe.flags & DBEF_SENT) != 0; bShowEventActions = item->dbe; -- cgit v1.2.3