summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-02 17:15:53 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-02 17:15:53 +0300
commit001d94fcefea15ea0bc6b42898bde6993ba1265e (patch)
treecad18b76fd6180c44de524331bc8a012c2685539 /src/mir_app
parentec497a784c0b6e43f45be4f5ca3b64970e045b05 (diff)
minor code optimization according to @tweimer's wish
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/srmm_base.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 33e06758d0..9813fc9f20 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -744,22 +744,22 @@ bool CSrmmBaseDialog::ProcessFileDrop(HDROP hDrop, MCONTACT 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
+// @return Returns true if processed here, returns false if should be processed elsewhere
-/**
-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)
+ if (db_get_b(0, CHAT_MODULE, "ShiftDropFilePasteURL", 1) == 0 || !isShift) // hidden setting: Chat/ShiftDropFilePasteURL
return false;
int fileCount = DragQueryFileW(hDrop, -1, nullptr, 0);
- CMStringW pasteString;
+ if (fileCount == 0)
+ return true;
+
+ CMStringW pasteString(L" ");
for (int i = 0; i < fileCount; i++) {
wchar_t szFilename[MAX_PATH];
if (DragQueryFileW(hDrop, i, szFilename, _countof(szFilename))) {
@@ -767,16 +767,12 @@ bool CSrmmBaseDialog::PasteFilesAsURL(HDROP hDrop)
fileString.Append(szFilename);
fileString.Replace(L"%", L"%25");
fileString.Replace(L" ", L"%20");
- 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());
-
+ m_message.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)pasteString.c_str());
return true;
}