annotate src/gui/widgets/drop_list_widget.cc @ 337:a7d4e5107531

dep/animone: REFACTOR ALL THE THINGS 1: animone now has its own syntax divergent from anisthesia, making different platforms actually have their own sections 2: process names in animone are now called `comm' (this will probably break things). this is what its called in bsd/linux so I'm just going to use it everywhere 3: the X11 code now checks for the existence of a UTF-8 window title and passes it if available 4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK! I still actually need to test the bsd code. to be honest I'm probably going to move all of the bsds into separate files because they're all essentially different operating systems at this point
author Paper <paper@paper.us.eu.org>
date Wed, 19 Jun 2024 12:51:15 -0400
parents b1f4d1867ab1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
1 #include "gui/widgets/drop_list_widget.h"
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
2
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
3 #include <QDragMoveEvent>
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
4 #include <QDropEvent>
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
5 #include <QMimeData>
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
6 #include <QFileInfo>
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
7
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
8 /* currently this only sends local paths that are folders */
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
9
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
10 DroppableListWidget::DroppableListWidget(QWidget* parent) : QListWidget(parent) {
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
11 setAcceptDrops(true);
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
12 }
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
13
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
14 void DroppableListWidget::dragMoveEvent(QDragMoveEvent* event) {
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
15 if (event->mimeData()->hasUrls())
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
16 event->acceptProposedAction();
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
17 }
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
18
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
19 void DroppableListWidget::dragEnterEvent(QDragEnterEvent* event) {
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
20 if (event->mimeData()->hasUrls())
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
21 event->acceptProposedAction();
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
22 }
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
23
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
24 void DroppableListWidget::dropEvent(QDropEvent* event) {
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
25 const QMimeData* mime_data = event->mimeData();
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
26
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
27 if (!mime_data->hasUrls())
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
28 return;
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
29
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
30 QStringList path_list;
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
31 QList<QUrl> url_list = mime_data->urls();
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
32
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
33 for (const auto& url : url_list) {
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
34 if (!url.isLocalFile())
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
35 continue;
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
36
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
37 const QString file = url.toLocalFile();
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
38 const QFileInfo fileinfo(file);
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
39 if (fileinfo.exists() && fileinfo.isDir())
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
40 path_list.append(file);
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
41 }
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
42
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
43 if (!path_list.isEmpty())
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
44 emit FilesDropped(path_list);
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
45
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
46 event->acceptProposedAction();
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
diff changeset
47 }