Mercurial > minori
annotate src/gui/dialog/information.cc @ 377:1b0b8e746d83 default tip
CI/windows: stupid msys2
| author | Paper <paper@tflc.us> |
|---|---|
| date | Fri, 25 Jul 2025 12:40:25 -0400 |
| parents | ea3a74ed2ef9 |
| children |
| rev | line source |
|---|---|
| 9 | 1 #include "gui/dialog/information.h" |
| 2 #include "core/anime.h" | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
3 #include "core/anime_db.h" |
| 258 | 4 #include "core/session.h" |
| 9 | 5 #include "core/strings.h" |
| 6 #include "gui/pages/anime_list.h" | |
| 7 #include "gui/translate/anime.h" | |
| 64 | 8 #include "gui/widgets/anime_info.h" |
| 76 | 9 #include "gui/widgets/optional_date.h" |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
10 #include "gui/widgets/poster.h" |
| 46 | 11 #include "gui/widgets/text.h" |
| 9 | 12 #include "gui/window.h" |
| 258 | 13 |
| 46 | 14 #include <QCheckBox> |
| 15 #include <QComboBox> | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
16 #include <QDateEdit> |
| 9 | 17 #include <QDebug> |
| 18 #include <QDialogButtonBox> | |
| 76 | 19 #include <QLabel> |
| 46 | 20 #include <QLineEdit> |
| 9 | 21 #include <QPlainTextEdit> |
| 46 | 22 #include <QSpinBox> |
| 23 #include <QStringList> | |
| 9 | 24 #include <QTextStream> |
| 25 #include <QVBoxLayout> | |
| 258 | 26 |
| 9 | 27 #include <functional> |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
28 #include <iostream> |
| 108 | 29 #ifdef WIN32 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
30 # include "sys/win32/dark_theme.h" |
| 108 | 31 #endif |
| 9 | 32 |
| 46 | 33 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, |
| 34 which sucks. Think of a better way to implement this later. */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
35 void InformationDialog::SaveData(Anime::Anime *anime) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
36 { |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
37 if (!anime->IsInUserList()) |
| 250 | 38 return; |
| 39 | |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
40 anime->SetUserProgress(_progress); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
41 anime->SetUserScore(_score); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
42 anime->SetUserIsRewatching(_rewatching); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
43 anime->SetUserStatus(_status); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
44 anime->SetUserNotes(_notes); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
45 anime->SetUserDateStarted(_started); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
46 anime->SetUserDateCompleted(_completed); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
47 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
48 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
49 InformationDialog::InformationDialog(Anime::Anime *anime, std::function<void(Anime::Anime *)> accept, enum Pages page, |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
50 QWidget *parent) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
51 : Dialog(parent) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
52 { |
| 258 | 53 /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ |
| 9 | 54 setFixedSize(842, 613); |
| 55 setWindowTitle(tr("Anime Information")); | |
| 56 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
| 36 | 57 |
| 58 { | |
|
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
89
diff
changeset
|
59 QPalette pal; |
| 69 | 60 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); |
| 36 | 61 setPalette(pal); |
| 62 } | |
| 9 | 63 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
64 QVBoxLayout *full_layout = new QVBoxLayout(this); |
| 108 | 65 |
| 66 { | |
| 67 /* this handles the actual page. */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
68 QWidget *widget = new QWidget(this); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
69 QHBoxLayout *layout = new QHBoxLayout(widget); |
| 108 | 70 |
| 71 { | |
| 72 /* Sidebar */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
73 QWidget *sidebar = new QWidget(widget); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
74 QVBoxLayout *sidebar_layout = new QVBoxLayout(sidebar); |
| 108 | 75 { |
| 76 /* Poster */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
77 Poster *poster = new Poster(*anime, sidebar); |
| 108 | 78 sidebar_layout->addWidget(poster); |
| 79 } | |
| 80 sidebar_layout->setContentsMargins(0, 0, 0, 0); | |
| 81 sidebar_layout->addStretch(); | |
| 82 layout->addWidget(sidebar); | |
| 83 } | |
| 84 | |
| 85 { | |
| 86 /* ... everything else. */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
87 QWidget *main_widget = new QWidget(widget); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
88 QVBoxLayout *main_layout = new QVBoxLayout(main_widget); |
| 108 | 89 |
| 90 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
| 9 | 91 |
| 108 | 92 { |
| 93 /* Anime title */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
94 TextWidgets::Title *anime_title = new TextWidgets::Title(main_widget); |
|
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
95 anime_title->SetText(anime->GetUserPreferredTitle()); |
| 108 | 96 main_layout->addWidget(anime_title); |
| 97 } | |
| 98 | |
| 99 { | |
| 100 /* Tab widget, contains main info and settings */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
101 QTabWidget *tabbed_widget = new QTabWidget(main_widget); |
| 253 | 102 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 9 | 103 |
| 108 | 104 { |
| 105 /* Main information */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
106 AnimeInfoWidget *main_information_widget = new AnimeInfoWidget(*anime, tabbed_widget); |
| 108 | 107 tabbed_widget->addTab(main_information_widget, tr("Main information")); |
| 108 } | |
| 36 | 109 |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
110 if (anime->IsInUserList()) { |
| 108 | 111 /* My list and settings */ |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
112 QWidget *settings_widget = new QWidget(tabbed_widget); |
| 108 | 113 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); |
| 9 | 114 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
115 QVBoxLayout *settings_layout = new QVBoxLayout(settings_widget); |
|
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
116 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
117 TextWidgets::Header *header = new TextWidgets::Header(settings_widget); |
|
348
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
118 header->SetText(Strings::Translate("Anime list")); |
|
6b0768158dcd
text: redesign almost every widget
Paper <paper@paper.us.eu.org>
parents:
324
diff
changeset
|
119 settings_layout->addWidget(header); |
| 108 | 120 |
| 121 { | |
| 122 /* Anime List */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
123 QWidget *sg_anime_list_content = new QWidget(settings_widget); |
| 9 | 124 |
| 108 | 125 constexpr int LAYOUT_HORIZ_SPACING = 25; |
| 258 | 126 constexpr int LAYOUT_VERT_SPACING = 5; |
| 127 constexpr int LAYOUT_ITEM_WIDTH = 175; | |
| 108 | 128 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
129 QVBoxLayout *al_layout = new QVBoxLayout(sg_anime_list_content); |
| 108 | 130 al_layout->setSpacing(LAYOUT_VERT_SPACING); |
| 131 al_layout->setContentsMargins(12, 0, 0, 0); | |
| 9 | 132 |
| 108 | 133 /* Helper function for creating sections, reduces clutter. */ |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
134 const auto CREATE_SECTION = [](QWidget *parent, |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
135 std::function<void(QWidget *, QGridLayout *)> x) { |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
136 QWidget *section = new QWidget(parent); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
137 QGridLayout *layout = new QGridLayout(section); |
| 108 | 138 layout->setHorizontalSpacing(LAYOUT_HORIZ_SPACING); |
| 139 layout->setVerticalSpacing(LAYOUT_VERT_SPACING); | |
| 140 layout->setContentsMargins(0, 0, 0, 0); | |
| 141 x(section, layout); | |
| 142 parent->layout()->addWidget(section); | |
| 143 }; | |
| 9 | 144 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
145 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { |
| 108 | 146 { |
| 147 /* Episodes watched... */ | |
| 148 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); | |
| 46 | 149 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
150 QSpinBox *spin_box = new QSpinBox(section); |
| 258 | 151 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
152 [this](int i) { _progress = i; }); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
153 spin_box->setRange(0, anime->GetEpisodes()); |
| 108 | 154 spin_box->setSingleStep(1); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
155 spin_box->setValue(_progress = anime->GetUserProgress()); |
| 108 | 156 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 157 layout->addWidget(spin_box, 1, 0); | |
| 158 } | |
| 46 | 159 |
| 108 | 160 { |
| 161 /* Rewatching? */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
162 QCheckBox *checkbox = new QCheckBox(tr("Rewatching")); |
| 108 | 163 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
164 [this](int state) { _rewatching = (state == Qt::Checked); }); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
165 checkbox->setCheckState((_rewatching = anime->GetUserIsRewatching()) ? Qt::Checked |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
166 : Qt::Unchecked); |
| 108 | 167 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 168 layout->addWidget(checkbox, 1, 1); | |
| 169 } | |
| 170 layout->setColumnStretch(layout->columnCount(), 1); | |
| 171 }); | |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
172 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
173 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { |
| 108 | 174 { |
| 175 /* Status */ | |
| 176 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); | |
| 177 | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
178 QComboBox *combo_box = new QComboBox(section); |
| 108 | 179 |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
180 _status = anime->GetUserStatus(); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
181 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) { |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
182 combo_box->addItem( |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
183 Strings::ToQString(Translate::ToLocalString(Anime::ListStatuses[i])), |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
184 static_cast<int>(Anime::ListStatuses[i])); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
185 if (Anime::ListStatuses[i] == _status) |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
186 combo_box->setCurrentIndex(i); |
|
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
187 } |
| 108 | 188 |
| 258 | 189 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
190 [this, combo_box](int) { |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
191 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
192 }); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
193 |
| 108 | 194 /* this should NEVER, EVER, be NOT_IN_LIST */ |
| 195 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | |
| 196 layout->addWidget(combo_box, 1, 0); | |
| 197 } | |
| 198 | |
| 199 { | |
| 200 /* Score */ | |
| 201 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); | |
| 202 | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
203 QSpinBox *spin_box = new QSpinBox(section); |
| 258 | 204 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
205 [this](int i) { _score = i; }); |
| 108 | 206 spin_box->setRange(0, 100); |
| 207 spin_box->setSingleStep(5); | |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
208 spin_box->setValue(_score = anime->GetUserScore()); |
| 108 | 209 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 210 layout->addWidget(spin_box, 1, 1); | |
| 211 } | |
| 212 layout->setColumnStretch(layout->columnCount(), 1); | |
| 213 }); | |
| 214 | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
215 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { |
| 108 | 216 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); |
| 64 | 217 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
218 QLineEdit *line_edit = new QLineEdit(section); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
219 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString &text) { |
| 108 | 220 /* this sucks but I don't really want to implement anything smarter :) */ |
| 221 _notes = Strings::ToUtf8String(text); | |
| 222 }); | |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
223 line_edit->setText(Strings::ToQString(_notes = anime->GetUserNotes())); |
| 108 | 224 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); |
| 225 layout->addWidget(line_edit, 1, 0); | |
| 226 }); | |
| 227 | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
228 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { |
| 108 | 229 /* Started */ |
| 230 { | |
| 231 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); | |
| 46 | 232 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
233 OptionalDate *date = new OptionalDate(true, section); |
| 108 | 234 connect(date, &OptionalDate::DataChanged, this, |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
235 [this](bool enabled, Date date) { _started = enabled ? date : Date(); }); |
| 108 | 236 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
237 _started = anime->GetUserDateStarted(); |
| 108 | 238 if (!_started.IsValid()) { |
| 239 date->SetEnabled(false); | |
|
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
240 _started = anime->GetStartedDate(); |
| 108 | 241 } |
| 242 date->SetDate(_started); | |
| 243 layout->addWidget(date, 1, 0); | |
| 244 } | |
| 245 | |
| 246 /* Completed */ | |
| 247 { | |
| 248 layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); | |
| 46 | 249 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
250 OptionalDate *date = new OptionalDate(true, section); |
| 108 | 251 connect(date, &OptionalDate::DataChanged, this, |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
252 [this](bool enabled, Date date) { _completed = enabled ? date : Date(); }); |
| 108 | 253 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
254 _completed = anime->GetUserDateCompleted(); |
| 108 | 255 if (!_completed.IsValid()) { |
| 256 date->SetEnabled(false); | |
|
324
5d3c9b31aa6e
anime: add completed date member
Paper <paper@paper.us.eu.org>
parents:
305
diff
changeset
|
257 _completed = anime->GetCompletedDate(); |
| 108 | 258 } |
| 259 date->SetDate(_completed); | |
| 260 layout->addWidget(date, 1, 1); | |
| 261 } | |
| 262 layout->setColumnStretch(layout->columnCount(), 1); | |
| 263 }); | |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
264 |
| 108 | 265 settings_layout->addWidget(sg_anime_list_content); |
| 266 } | |
| 267 | |
| 268 /* | |
| 269 { | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
270 // commenting this out until it actually gets implemented :) |
| 46 | 271 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
272 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); |
| 108 | 273 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
274 QWidget* sg_local_content = new QWidget(settings_widget); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
275 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
276 sg_local_layout->setSpacing(5); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
277 sg_local_layout->setContentsMargins(12, 0, 0, 0); |
| 108 | 278 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
279 CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
280 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); |
|
89
e6fab256ddc4
dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents:
88
diff
changeset
|
281 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
282 QLineEdit* line_edit = new QLineEdit("", section); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
283 line_edit->setPlaceholderText( |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
284 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
285 layout->addWidget(line_edit, 1, 0); |
| 108 | 286 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
287 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for |
| 258 | 288 torrents")); layout->addWidget(checkbox, 2, 0); |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
289 }); |
| 108 | 290 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
291 settings_layout->addWidget(sg_local_content); |
| 108 | 292 } |
| 293 */ | |
| 294 | |
| 295 settings_layout->addStretch(); | |
| 46 | 296 |
| 108 | 297 tabbed_widget->addTab(settings_widget, tr("My list and settings")); |
| 298 } | |
|
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
299 tabbed_widget->setCurrentIndex(static_cast<int>(page)); |
| 108 | 300 main_layout->addWidget(tabbed_widget); |
| 301 main_layout->setContentsMargins(0, 0, 0, 0); | |
| 302 main_layout->setSpacing(12); | |
| 303 } | |
|
89
e6fab256ddc4
dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents:
88
diff
changeset
|
304 |
| 108 | 305 layout->addWidget(main_widget); |
| 306 } | |
| 307 layout->setSpacing(12); | |
| 294 | 308 layout->setContentsMargins(0, 0, 0, 0); |
| 108 | 309 full_layout->addWidget(widget); |
| 310 } | |
| 46 | 311 |
| 108 | 312 { |
| 313 /* Dialog box buttons */ | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
314 QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
315 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept, anime] { |
| 108 | 316 SaveData(anime); |
|
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
294
diff
changeset
|
317 accept(anime); |
| 108 | 318 QDialog::accept(); |
|
89
e6fab256ddc4
dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents:
88
diff
changeset
|
319 }); |
| 108 | 320 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 321 full_layout->addWidget(button_box, 0, Qt::AlignBottom); | |
| 322 } | |
| 323 } |
