Skip to content

Commit

Permalink
Only accept drop of single file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHal committed Dec 6, 2024
1 parent 011a720 commit 3c3934c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions QtPMbrowser/pmbrowserwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,11 +1154,13 @@ void PMbrowserWindow::dragEnterEvent(QDragEnterEvent* event)
auto mimedata = event->mimeData();
if (mimedata->hasUrls()) {
auto urls = mimedata->urls();
auto& url = urls[0];
if (url.isLocalFile()) {
auto filename = url.toLocalFile();
if (filename.endsWith(".dat")) {
event->acceptProposedAction();
if (urls.length() == 1) { // only accept 1 file at a time
auto& url = urls[0];
if (url.isLocalFile()) {
auto filename = url.toLocalFile();
if (filename.endsWith(".dat")) {
event->acceptProposedAction();
}
}
}
}
Expand All @@ -1171,12 +1173,14 @@ void PMbrowserWindow::dropEvent(QDropEvent* event)
auto mimedata = event->mimeData();
if (mimedata->hasUrls()) {
auto urls = mimedata->urls();
auto& url = urls[0];
if (url.isLocalFile()) {
auto filename = url.toLocalFile();
if (filename.endsWith(".dat")) {
loadFile(filename);
event->acceptProposedAction();
if (urls.length() == 1) {
auto& url = urls[0];
if (url.isLocalFile()) {
auto filename = url.toLocalFile();
if (filename.endsWith(".dat")) {
loadFile(filename);
event->acceptProposedAction();
}
}
}
}
Expand Down

0 comments on commit 3c3934c

Please sign in to comment.