Mercurial > minori
comparison src/gui/dialog/settings/library.cc @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Mon, 01 Apr 2024 02:43:44 -0400 |
| parents | 4d461ef7d424 |
| children | b1f4d1867ab1 |
comparison
equal
deleted
inserted
replaced
| 257:699a20c57dc8 | 258:862d0d8619f6 |
|---|---|
| 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 | 4 |
| 5 #include <QCheckBox> | |
| 6 #include <QDir> | |
| 7 #include <QDropEvent> | |
| 8 #include <QFileDialog> | |
| 9 #include <QFileInfo> | |
| 10 #include <QGroupBox> | |
| 11 #include <QLabel> | |
| 5 #include <QListWidget> | 12 #include <QListWidget> |
| 6 #include <QListWidgetItem> | 13 #include <QListWidgetItem> |
| 7 #include <QGroupBox> | 14 #include <QMimeData> |
| 8 #include <QCheckBox> | 15 #include <QPushButton> |
| 9 #include <QLabel> | |
| 10 #include <QSizePolicy> | 16 #include <QSizePolicy> |
| 11 #include <QVBoxLayout> | 17 #include <QVBoxLayout> |
| 12 #include <QDir> | |
| 13 #include <QFileDialog> | |
| 14 #include <QFileInfo> | |
| 15 #include <QPushButton> | |
| 16 #include <QDropEvent> | |
| 17 #include <QMimeData> | |
| 18 | 18 |
| 19 #include <algorithm> | 19 #include <algorithm> |
| 20 #include <iostream> | 20 #include <iostream> |
| 21 | 21 |
| 22 DroppableListWidget::DroppableListWidget(QWidget* parent) : QListWidget(parent) { | 22 DroppableListWidget::DroppableListWidget(QWidget* parent) : QListWidget(parent) { |
| 23 setAcceptDrops(true); | 23 setAcceptDrops(true); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void DroppableListWidget::dragMoveEvent(QDragMoveEvent* event) { | 26 void DroppableListWidget::dragMoveEvent(QDragMoveEvent* event) { |
| 27 if (event->mimeData()->hasUrls()) | 27 if (event->mimeData()->hasUrls()) |
| 28 event->acceptProposedAction(); | 28 event->acceptProposedAction(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void DroppableListWidget::dragEnterEvent(QDragEnterEvent* event) { | 31 void DroppableListWidget::dragEnterEvent(QDragEnterEvent* event) { |
| 32 if (event->mimeData()->hasUrls()) | 32 if (event->mimeData()->hasUrls()) |
| 33 event->acceptProposedAction(); | 33 event->acceptProposedAction(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void DroppableListWidget::dropEvent(QDropEvent* event) { | 36 void DroppableListWidget::dropEvent(QDropEvent* event) { |
| 37 const QMimeData* mime_data = event->mimeData(); | 37 const QMimeData* mime_data = event->mimeData(); |
| 38 | 38 |
| 83 QListWidgetItem* item = new QListWidgetItem(listwidget); | 83 QListWidgetItem* item = new QListWidgetItem(listwidget); |
| 84 item->setText(Strings::ToQString(path)); | 84 item->setText(Strings::ToQString(path)); |
| 85 /* add icons as well soon */ | 85 /* add icons as well soon */ |
| 86 } | 86 } |
| 87 | 87 |
| 88 connect(listwidget, &DroppableListWidget::FilesDropped, this, [this, listwidget](QStringList list){ | 88 connect(listwidget, &DroppableListWidget::FilesDropped, this, [this, listwidget](QStringList list) { |
| 89 for (const auto& dir : list) { | 89 for (const auto& dir : list) { |
| 90 paths.insert(Strings::ToUtf8String(dir)); | 90 paths.insert(Strings::ToUtf8String(dir)); |
| 91 QListWidgetItem* item = new QListWidgetItem(listwidget); | 91 QListWidgetItem* item = new QListWidgetItem(listwidget); |
| 92 item->setText(dir); | 92 item->setText(dir); |
| 93 } | 93 } |
| 107 widget_layout->addStretch(); | 107 widget_layout->addStretch(); |
| 108 | 108 |
| 109 { | 109 { |
| 110 QPushButton* button = new QPushButton(tr("Add new..."), widget); | 110 QPushButton* button = new QPushButton(tr("Add new..."), widget); |
| 111 | 111 |
| 112 connect(button, &QPushButton::clicked, this, [this, listwidget]{ | 112 connect(button, &QPushButton::clicked, this, [this, listwidget] { |
| 113 const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), | 113 const QString dir = QFileDialog::getExistingDirectory( |
| 114 QDir::homePath(), | 114 this, tr("Open Directory"), QDir::homePath(), |
| 115 QFileDialog::ShowDirsOnly | 115 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); |
| 116 | QFileDialog::DontResolveSymlinks); | |
| 117 const std::string s_dir = Strings::ToUtf8String(dir); | 116 const std::string s_dir = Strings::ToUtf8String(dir); |
| 118 if (dir.isEmpty() || paths.count(s_dir)) | 117 if (dir.isEmpty() || paths.count(s_dir)) |
| 119 return; | 118 return; |
| 120 | 119 |
| 121 paths.insert(s_dir); | 120 paths.insert(s_dir); |
| 127 } | 126 } |
| 128 | 127 |
| 129 { | 128 { |
| 130 QPushButton* button = new QPushButton(tr("Remove"), widget); | 129 QPushButton* button = new QPushButton(tr("Remove"), widget); |
| 131 | 130 |
| 132 connect(listwidget, &QListWidget::itemSelectionChanged, this, [button, listwidget]{ | 131 connect(listwidget, &QListWidget::itemSelectionChanged, this, [button, listwidget] { |
| 133 QList<QListWidgetItem*> selection = listwidget->selectedItems(); | 132 QList<QListWidgetItem*> selection = listwidget->selectedItems(); |
| 134 button->setEnabled(selection.size() > 0); | 133 button->setEnabled(selection.size() > 0); |
| 135 }); | 134 }); |
| 136 | 135 |
| 137 connect(button, &QPushButton::clicked, this, [this, listwidget]{ | 136 connect(button, &QPushButton::clicked, this, [this, listwidget] { |
| 138 QList<QListWidgetItem*> selection = listwidget->selectedItems(); | 137 QList<QListWidgetItem*> selection = listwidget->selectedItems(); |
| 139 for (const auto& item : selection) { | 138 for (const auto& item : selection) { |
| 140 paths.erase(Strings::ToUtf8String(item->text())); | 139 paths.erase(Strings::ToUtf8String(item->text())); |
| 141 delete item; | 140 delete item; |
| 142 } | 141 } |
| 160 | 159 |
| 161 { | 160 { |
| 162 QCheckBox* checkbox = new QCheckBox(tr("Detect new files and folders under library folders"), group_box); | 161 QCheckBox* checkbox = new QCheckBox(tr("Detect new files and folders under library folders"), group_box); |
| 163 checkbox->setCheckState(real_time_monitor ? Qt::Checked : Qt::Unchecked); | 162 checkbox->setCheckState(real_time_monitor ? Qt::Checked : Qt::Unchecked); |
| 164 | 163 |
| 165 connect(checkbox, &QCheckBox::stateChanged, this, [this](int state) { | 164 connect(checkbox, &QCheckBox::stateChanged, this, |
| 166 real_time_monitor = (state != Qt::Unchecked); | 165 [this](int state) { real_time_monitor = (state != Qt::Unchecked); }); |
| 167 }); | |
| 168 | 166 |
| 169 group_box_layout->addWidget(checkbox); | 167 group_box_layout->addWidget(checkbox); |
| 170 } | 168 } |
| 171 | 169 |
| 172 full_layout->addWidget(group_box); | 170 full_layout->addWidget(group_box); |
| 182 session.config.library.paths = paths; | 180 session.config.library.paths = paths; |
| 183 session.config.library.real_time_monitor = real_time_monitor; | 181 session.config.library.real_time_monitor = real_time_monitor; |
| 184 } | 182 } |
| 185 | 183 |
| 186 SettingsPageLibrary::SettingsPageLibrary(QWidget* parent) | 184 SettingsPageLibrary::SettingsPageLibrary(QWidget* parent) |
| 187 : SettingsPage(parent, tr("Library")), | 185 : SettingsPage(parent, tr("Library")), paths(session.config.library.paths) { |
| 188 paths(session.config.library.paths) { | |
| 189 real_time_monitor = session.config.library.real_time_monitor; | 186 real_time_monitor = session.config.library.real_time_monitor; |
| 190 AddTab(CreateFoldersWidget(), tr("Folder")); | 187 AddTab(CreateFoldersWidget(), tr("Folder")); |
| 191 } | 188 } |
