annotate src/gui/dialog/settings/library.cc @ 232:ff0061e75f0f

theme: add OS detection with glib
author Paper <mrpapersonic@gmail.com>
date Sat, 13 Jan 2024 11:06:16 -0500
parents d030b30526d5
children 4d461ef7d424
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
226
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "core/session.h"
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/strings.h"
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include "gui/dialog/settings.h"
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <QListWidget>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QListWidgetItem>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QGroupBox>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <QCheckBox>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 #include <QLabel>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 #include <QSizePolicy>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #include <QVBoxLayout>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #include <QDir>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 #include <QFileDialog>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 #include <QFileInfo>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 #include <QPushButton>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 #include <QDropEvent>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 #include <QMimeData>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 #include <algorithm>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 #include <iostream>
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 class DroppableListWidget : public QListWidget {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 Q_OBJECT
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 public:
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 explicit DroppableListWidget(QWidget* parent);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 signals:
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 void FilesDropped(QStringList list);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 protected:
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 void dragEnterEvent(QDragEnterEvent* event) override;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 void dragMoveEvent(QDragMoveEvent* event) override;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 void dropEvent(QDropEvent* event) override;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 };
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 DroppableListWidget::DroppableListWidget(QWidget* parent) : QListWidget(parent) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 setAcceptDrops(true);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 void DroppableListWidget::dragMoveEvent(QDragMoveEvent* event) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 if (event->mimeData()->hasUrls())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 event->acceptProposedAction();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 void DroppableListWidget::dragEnterEvent(QDragEnterEvent* event) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 if (event->mimeData()->hasUrls())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 event->acceptProposedAction();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 void DroppableListWidget::dropEvent(QDropEvent* event) {
228
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 226
diff changeset
52 const QMimeData* mime_data = event->mimeData();
226
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 if (!mime_data->hasUrls())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 return;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 QStringList path_list;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 QList<QUrl> url_list = mime_data->urls();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 for (const auto& url : url_list) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 if (!url.isLocalFile())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 continue;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 const QString file = url.toLocalFile();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 const QFileInfo fileinfo(file);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 if (fileinfo.exists() && fileinfo.isDir())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67 path_list.append(file);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 if (!path_list.isEmpty())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 emit FilesDropped(path_list);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 event->acceptProposedAction();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 QWidget* SettingsPageLibrary::CreateFoldersWidget() {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 QWidget* result = new QWidget(this);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 QVBoxLayout* full_layout = new QVBoxLayout(result);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 QGroupBox* group_box = new QGroupBox(tr("Library folders"), result);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 QVBoxLayout* group_box_layout = new QVBoxLayout(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 QLabel* label = new QLabel(tr("These folders will be scanned and monitored for new episodes."), group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 group_box_layout->addWidget(label);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 DroppableListWidget* listwidget = new DroppableListWidget(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 listwidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 for (const auto& path : paths) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 QListWidgetItem* item = new QListWidgetItem(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 item->setText(Strings::ToQString(path));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 /* add icons as well soon */
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 connect(listwidget, &DroppableListWidget::FilesDropped, this, [this, listwidget](QStringList list){
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 for (const auto& dir : list) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 paths.insert(Strings::ToUtf8String(dir));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 QListWidgetItem* item = new QListWidgetItem(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 item->setText(dir);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109 });
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111 group_box_layout->addWidget(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114 QWidget* widget = new QWidget(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 QHBoxLayout* widget_layout = new QHBoxLayout(widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
118 QLabel* label = new QLabel(tr("Tip: You can drag and drop folders here."), widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 widget_layout->addWidget(label);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
121
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
122 widget_layout->addStretch();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
123
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
124 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125 QPushButton* button = new QPushButton(tr("Add new..."), widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127 connect(button, &QPushButton::clicked, this, [this, listwidget]{
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129 QDir::homePath(),
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130 QFileDialog::ShowDirsOnly
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 | QFileDialog::DontResolveSymlinks);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 if (dir.isEmpty())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 return;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134 paths.insert(Strings::ToUtf8String(dir));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 QListWidgetItem* item = new QListWidgetItem(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 item->setText(dir);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 });
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139 widget_layout->addWidget(button);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
143 QPushButton* button = new QPushButton(tr("Remove"), widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
144
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 connect(listwidget, &QListWidget::itemSelectionChanged, this, [button, listwidget]{
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 QList<QListWidgetItem*> selection = listwidget->selectedItems();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147 button->setEnabled(selection.size() > 0);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 });
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
149
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150 connect(button, &QPushButton::clicked, this, [this, listwidget]{
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 QList<QListWidgetItem*> selection = listwidget->selectedItems();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 for (const auto& item : selection) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 paths.erase(Strings::ToUtf8String(item->text()));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 delete item;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 });
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 widget_layout->addWidget(button);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 group_box_layout->addWidget(widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 full_layout->addWidget(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
168 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169 QGroupBox* group_box = new QGroupBox(tr("Real-time monitor"), result);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172 QVBoxLayout* group_box_layout = new QVBoxLayout(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
173
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
174 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 QCheckBox* checkbox = new QCheckBox(tr("Detect new files and folders under library folders"), group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
176 checkbox->setCheckState(real_time_monitor ? Qt::Checked : Qt::Unchecked);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
177
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
178 connect(checkbox, &QCheckBox::stateChanged, this, [this](int state) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
179 real_time_monitor = (state != Qt::Unchecked);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
180 });
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
182 group_box_layout->addWidget(checkbox);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
183 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
185 full_layout->addWidget(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
186 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
187
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
188 full_layout->setSpacing(10);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
189 full_layout->addStretch();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
191 return result;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
192 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
193
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
194 void SettingsPageLibrary::SaveInfo() {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
195 session.config.library.paths = paths;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
196 session.config.library.real_time_monitor = real_time_monitor;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
197 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
198
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
199 SettingsPageLibrary::SettingsPageLibrary(QWidget* parent)
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
200 : SettingsPage(parent, tr("Library")),
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
201 paths(session.config.library.paths) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
202 real_time_monitor = session.config.library.real_time_monitor;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
203 AddTab(CreateFoldersWidget(), tr("Folder"));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
204 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
205
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
206 #include "gui/dialog/settings/library.moc"