diff options
-rw-r--r-- | include/m_srmm_int.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h index 5c0e75e27f..28b67984b4 100644 --- a/include/m_srmm_int.h +++ b/include/m_srmm_int.h @@ -197,6 +197,7 @@ protected: int NotifyEvent(int code); bool ProcessFileDrop(HDROP hDrop, MCONTACT hContact); + bool PasteFilesAsURL(HDROP hDrop); bool ProcessHotkeys(int key, bool bShift, bool bCtrl, bool bAlt); void RefreshButtonStatus(void); void RunUserMenu(HWND hwndOwner, struct USERINFO *ui, const POINT &pt); diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 78e14711eb..2faeba337a 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -737,11 +737,49 @@ int CSrmmBaseDialog::NotifyEvent(int code) bool CSrmmBaseDialog::ProcessFileDrop(HDROP hDrop, MCONTACT hContact) { + if (PasteFilesAsURL(hDrop)) + return true; + return ::ProcessFileDrop(hDrop, hContact); } ///////////////////////////////////////////////////////////////////////////////////////// +/** +If enabled pastes droped files as list of URL of file:/// type + Can be enabled/disabled by Chat/ShiftDropFilePasteURL database parameter +@param hDrop Drop handle +@param hContact Contact handle +@return Returns true if processed here, returns false if should be processed elsewhere +*/ +bool CSrmmBaseDialog::PasteFilesAsURL(HDROP hDrop) +{ + bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; + if (db_get_b(0, CHAT_MODULE, "ShiftDropFilePasteURL", 1) == 0 || !isShift) + return false; + + int fileCount = DragQueryFileW(hDrop, -1, nullptr, 0); + CMStringW pasteString; + for (int i = 0; i < fileCount; i++) { + wchar_t szFilename[MAX_PATH]; + if (DragQueryFileW(hDrop, i, szFilename, _countof(szFilename))) { + CMStringW fileString(L"file:///"); + fileString.Append(_A2T(mir_urlEncode(T2Utf(szFilename)))); + if (i == 0) + fileString.Insert(0, L" "); + fileString.Append((i != fileCount - 1) ? L"\r\n" : L" "); + pasteString += fileString; + } + } + + if (pasteString.GetLength()) + m_message.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)pasteString.c_str()); + + return true; +} + +///////////////////////////////////////////////////////////////////////////////////////// + bool CSrmmBaseDialog::ProcessHotkeys(int key, bool isShift, bool isCtrl, bool isAlt) { // Esc (close tab) |