diff options
author | George Hazan <ghazan@miranda.im> | 2020-06-01 17:01:42 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-06-01 17:01:42 +0300 |
commit | b1226db758ddef092db6eb036abc6513cc06c26f (patch) | |
tree | 2499e46c3d04d4f3e7147575d48a86ac9a27b7b9 /src/mir_app | |
parent | f515f0b6947691d8416b9e8ea585afce97bca5c9 (diff) |
fixes #2412 (Add ability to paste file URL instead of file sending initiation)
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
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) |