annotate src/gui/dialog/settings/library.cc @ 226:f784b5b1914c

settings: add library page
author Paper <mrpapersonic@gmail.com>
date Mon, 08 Jan 2024 21:23:00 -0500
parents
children d030b30526d5
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) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 const QMimeData *mime_data = event->mimeData();
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->setAutoFillBackground(true);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 QVBoxLayout* full_layout = new QVBoxLayout(result);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 QGroupBox* group_box = new QGroupBox(tr("Library folders"), result);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 QVBoxLayout* group_box_layout = new QVBoxLayout(group_box);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 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
91 group_box_layout->addWidget(label);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 DroppableListWidget* listwidget = new DroppableListWidget(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 listwidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 for (const auto& path : paths) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 QListWidgetItem* item = new QListWidgetItem(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 item->setText(Strings::ToQString(path));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 /* add icons as well soon */
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 connect(listwidget, &DroppableListWidget::FilesDropped, this, [this, listwidget](QStringList list){
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 for (const auto& dir : list) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 paths.insert(Strings::ToUtf8String(dir));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 QListWidgetItem* item = new QListWidgetItem(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 item->setText(dir);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112 group_box_layout->addWidget(listwidget);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 QWidget* widget = new QWidget(group_box);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 QHBoxLayout* widget_layout = new QHBoxLayout(widget);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 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
120 widget_layout->addWidget(label);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
123 widget_layout->addStretch();
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126 QPushButton* button = new QPushButton(tr("Add new..."), widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 connect(button, &QPushButton::clicked, this, [this, listwidget]{
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129 const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130 QDir::homePath(),
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 QFileDialog::ShowDirsOnly
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 | QFileDialog::DontResolveSymlinks);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 if (dir.isEmpty())
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134 return;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 paths.insert(Strings::ToUtf8String(dir));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 QListWidgetItem* item = new QListWidgetItem(listwidget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 item->setText(dir);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 widget_layout->addWidget(button);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
144 QPushButton* button = new QPushButton(tr("Remove"), widget);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 connect(listwidget, &QListWidget::itemSelectionChanged, this, [button, listwidget]{
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147 QList<QListWidgetItem*> selection = listwidget->selectedItems();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 button->setEnabled(selection.size() > 0);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 connect(button, &QPushButton::clicked, this, [this, listwidget]{
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 QList<QListWidgetItem*> selection = listwidget->selectedItems();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 for (const auto& item : selection) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 paths.erase(Strings::ToUtf8String(item->text()));
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 delete item;
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159 widget_layout->addWidget(button);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 group_box_layout->addWidget(widget);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 full_layout->addWidget(group_box);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 QGroupBox* group_box = new QGroupBox(tr("Real-time monitor"), result);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
173 QVBoxLayout* group_box_layout = new QVBoxLayout(group_box);
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 {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
176 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
177 checkbox->setCheckState(real_time_monitor ? Qt::Checked : Qt::Unchecked);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
178
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
179 connect(checkbox, &QCheckBox::stateChanged, this, [this](int state) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
180 real_time_monitor = (state != Qt::Unchecked);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
183 group_box_layout->addWidget(checkbox);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
186 full_layout->addWidget(group_box);
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
189 full_layout->setSpacing(10);
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190 full_layout->addStretch();
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
191
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
192 return result;
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
195 void SettingsPageLibrary::SaveInfo() {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
196 session.config.library.paths = paths;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
197 session.config.library.real_time_monitor = real_time_monitor;
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
200 SettingsPageLibrary::SettingsPageLibrary(QWidget* parent)
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
201 : SettingsPage(parent, tr("Library")),
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
202 paths(session.config.library.paths) {
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
203 real_time_monitor = session.config.library.real_time_monitor;
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
204 AddTab(CreateFoldersWidget(), tr("Folder"));
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
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
207 #include "gui/dialog/settings/library.moc"