diff options
author | George Hazan <george.hazan@gmail.com> | 2024-03-26 17:07:59 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-03-26 17:07:59 +0300 |
commit | a31a63bc46df07569bb05c69fb027d6edc0aee3d (patch) | |
tree | f04d46bf19b331e4edc58edf4b391efc294ccd7c | |
parent | 610cc3376a2b7e24542594be4899b1dd9ebd7d66 (diff) |
fixes #4305 (NewStory: пункт меню "копировать ссылку")
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 9 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 8 | ||||
-rw-r--r-- | plugins/NewStory/src/history_menus.cpp | 2 |
4 files changed, 18 insertions, 2 deletions
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;
|