Mercurial > minori
comparison src/gui/dialog/settings/library.cc @ 317:b1f4d1867ab1
services: VERY initial Kitsu support
it only supports user authentication for now, but it's definitely
a start.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 04:07:10 -0400 |
parents | 862d0d8619f6 |
children |
comparison
equal
deleted
inserted
replaced
316:180714442770 | 317:b1f4d1867ab1 |
---|---|
1 #include "core/session.h" | 1 #include "core/session.h" |
2 #include "core/strings.h" | 2 #include "core/strings.h" |
3 #include "gui/dialog/settings.h" | 3 #include "gui/dialog/settings.h" |
4 #include "gui/widgets/drop_list_widget.h" | |
4 | 5 |
5 #include <QCheckBox> | 6 #include <QCheckBox> |
6 #include <QDir> | 7 #include <QDir> |
7 #include <QDropEvent> | |
8 #include <QFileDialog> | 8 #include <QFileDialog> |
9 #include <QFileInfo> | |
10 #include <QGroupBox> | 9 #include <QGroupBox> |
11 #include <QLabel> | 10 #include <QLabel> |
12 #include <QListWidget> | 11 #include <QListWidget> |
13 #include <QListWidgetItem> | 12 #include <QListWidgetItem> |
14 #include <QMimeData> | |
15 #include <QPushButton> | 13 #include <QPushButton> |
16 #include <QSizePolicy> | 14 #include <QSizePolicy> |
17 #include <QVBoxLayout> | 15 #include <QVBoxLayout> |
18 | |
19 #include <algorithm> | |
20 #include <iostream> | |
21 | |
22 DroppableListWidget::DroppableListWidget(QWidget* parent) : QListWidget(parent) { | |
23 setAcceptDrops(true); | |
24 } | |
25 | |
26 void DroppableListWidget::dragMoveEvent(QDragMoveEvent* event) { | |
27 if (event->mimeData()->hasUrls()) | |
28 event->acceptProposedAction(); | |
29 } | |
30 | |
31 void DroppableListWidget::dragEnterEvent(QDragEnterEvent* event) { | |
32 if (event->mimeData()->hasUrls()) | |
33 event->acceptProposedAction(); | |
34 } | |
35 | |
36 void DroppableListWidget::dropEvent(QDropEvent* event) { | |
37 const QMimeData* mime_data = event->mimeData(); | |
38 | |
39 if (!mime_data->hasUrls()) | |
40 return; | |
41 | |
42 QStringList path_list; | |
43 QList<QUrl> url_list = mime_data->urls(); | |
44 | |
45 for (const auto& url : url_list) { | |
46 if (!url.isLocalFile()) | |
47 continue; | |
48 | |
49 const QString file = url.toLocalFile(); | |
50 const QFileInfo fileinfo(file); | |
51 if (fileinfo.exists() && fileinfo.isDir()) | |
52 path_list.append(file); | |
53 } | |
54 | |
55 if (!path_list.isEmpty()) | |
56 emit FilesDropped(path_list); | |
57 | |
58 event->acceptProposedAction(); | |
59 } | |
60 | 16 |
61 QWidget* SettingsPageLibrary::CreateFoldersWidget() { | 17 QWidget* SettingsPageLibrary::CreateFoldersWidget() { |
62 QWidget* result = new QWidget(this); | 18 QWidget* result = new QWidget(this); |
63 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | 19 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); |
64 | 20 |