Mercurial > minori
comparison src/gui/dialog/settings/torrents.cc @ 116:254b1d2b7096
settings: add torrents page, make rss feed configurable
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 13:52:13 -0500 |
parents | |
children | 4eae379cb1ff |
comparison
equal
deleted
inserted
replaced
115:c72b907b9bef | 116:254b1d2b7096 |
---|---|
1 #include "core/session.h" | |
2 #include "core/strings.h" | |
3 #include "gui/dialog/settings.h" | |
4 #include <QLineEdit> | |
5 #include <QGroupBox> | |
6 #include <QLabel> | |
7 #include <QSizePolicy> | |
8 #include <QVBoxLayout> | |
9 #include <algorithm> | |
10 | |
11 QWidget* SettingsPageTorrents::CreateGeneralWidget() { | |
12 QWidget* result = new QWidget(this); | |
13 result->setAutoFillBackground(true); | |
14 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
15 | |
16 QVBoxLayout* full_layout = new QVBoxLayout(result); | |
17 | |
18 { | |
19 /* URLs */ | |
20 QGroupBox* group = new QGroupBox(tr("URLs"), result); | |
21 group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
22 | |
23 QVBoxLayout* group_layout = new QVBoxLayout(group); | |
24 | |
25 { | |
26 /* Feed link */ | |
27 QWidget* widget = new QWidget(group); | |
28 QVBoxLayout* widget_layout = new QVBoxLayout(widget); | |
29 | |
30 { | |
31 QLabel* sync_combo_box_label = new QLabel(tr("URL of the RSS feed to check:"), widget); | |
32 widget_layout->addWidget(sync_combo_box_label); | |
33 } | |
34 | |
35 { | |
36 /* Username: this literally never gets used btw */ | |
37 QLineEdit* lineedit = new QLineEdit(Strings::ToQString(feed_link), widget); | |
38 connect(lineedit, &QLineEdit::editingFinished, this, | |
39 [this, lineedit] { feed_link = Strings::ToUtf8String(lineedit->text()); }); | |
40 widget_layout->addWidget(lineedit); | |
41 } | |
42 | |
43 group_layout->addWidget(widget); | |
44 } | |
45 | |
46 full_layout->addWidget(group); | |
47 } | |
48 | |
49 full_layout->setSpacing(10); | |
50 full_layout->addStretch(); | |
51 | |
52 return result; | |
53 } | |
54 | |
55 void SettingsPageTorrents::SaveInfo() { | |
56 session.config.torrents.feed_link = feed_link; | |
57 } | |
58 | |
59 SettingsPageTorrents::SettingsPageTorrents(QWidget* parent) : SettingsPage(parent, tr("Application")) { | |
60 feed_link = session.config.torrents.feed_link; | |
61 AddTab(CreateGeneralWidget(), tr("General")); | |
62 } |