Mercurial > minori
annotate src/gui/dialog/information.cc @ 88:1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Tue, 31 Oct 2023 16:18:26 -0400 |
| parents | 4aef97f4d998 |
| children | e6fab256ddc4 |
| 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" |
| 9 | 4 #include "core/strings.h" |
| 5 #include "gui/pages/anime_list.h" | |
| 6 #include "gui/translate/anime.h" | |
| 64 | 7 #include "gui/widgets/anime_info.h" |
| 76 | 8 #include "gui/widgets/optional_date.h" |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
9 #include "gui/widgets/poster.h" |
| 46 | 10 #include "gui/widgets/text.h" |
| 9 | 11 #include "gui/window.h" |
| 46 | 12 #include <QCheckBox> |
| 13 #include <QComboBox> | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
14 #include <QDateEdit> |
| 9 | 15 #include <QDebug> |
| 16 #include <QDialogButtonBox> | |
| 76 | 17 #include <QLabel> |
| 46 | 18 #include <QLineEdit> |
| 9 | 19 #include <QPlainTextEdit> |
| 46 | 20 #include <QSpinBox> |
| 21 #include <QStringList> | |
| 9 | 22 #include <QTextStream> |
| 23 #include <QVBoxLayout> | |
| 24 #include <functional> | |
| 25 | |
| 46 | 26 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, |
| 27 which sucks. Think of a better way to implement this later. */ | |
| 83 | 28 void InformationDialog::SaveData(Anime::Anime& anime) { |
| 29 anime.SetUserProgress(_progress); | |
| 30 anime.SetUserScore(_score); | |
| 31 anime.SetUserIsRewatching(_rewatching); | |
| 32 anime.SetUserStatus(_status); | |
| 33 anime.SetUserNotes(_notes); | |
| 34 anime.SetUserDateStarted(_started); | |
| 35 anime.SetUserDateCompleted(_completed); | |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
36 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
37 |
| 83 | 38 InformationDialog::InformationDialog(Anime::Anime& anime, std::function<void()> accept, QWidget* parent) |
| 15 | 39 : QDialog(parent) { |
| 9 | 40 setFixedSize(842, 613); |
| 41 setWindowTitle(tr("Anime Information")); | |
| 42 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
| 36 | 43 |
| 44 { | |
| 69 | 45 QPalette pal(palette()); |
| 46 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
| 36 | 47 setPalette(pal); |
| 48 } | |
| 9 | 49 |
| 50 QWidget* widget = new QWidget(this); | |
| 51 | |
| 52 /* "sidebar", includes... just the anime image :) */ | |
| 53 QWidget* sidebar = new QWidget(widget); | |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
54 QVBoxLayout* sidebar_layout = new QVBoxLayout(sidebar); |
| 83 | 55 Poster* poster = new Poster(anime, sidebar); |
|
66
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
56 sidebar_layout->addWidget(poster); |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
57 sidebar_layout->setContentsMargins(0, 0, 0, 0); |
|
6481c5aed3e1
posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
58 sidebar_layout->addStretch(); |
| 9 | 59 |
| 60 /* main widget */ | |
| 61 QWidget* main_widget = new QWidget(widget); | |
| 36 | 62 |
| 9 | 63 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 64 | |
| 65 /* anime title header text */ | |
| 64 | 66 TextWidgets::Title* anime_title = |
|
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
67 new TextWidgets::Title(Strings::ToQString(anime.GetUserPreferredTitle()), main_widget); |
| 9 | 68 |
| 69 /* tabbed widget */ | |
| 70 QTabWidget* tabbed_widget = new QTabWidget(main_widget); | |
| 71 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | |
| 72 | |
| 73 /* main info tab */ | |
| 64 | 74 AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget); |
| 9 | 75 |
| 69 | 76 { |
| 77 QPalette pal(main_information_widget->palette()); | |
| 78 pal.setColor(QPalette::Base, pal.color(QPalette::Window)); | |
| 79 main_information_widget->setPalette(pal); | |
| 80 } | |
| 81 | |
| 9 | 82 QWidget* settings_widget = new QWidget(tabbed_widget); |
| 46 | 83 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); |
| 84 | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
85 QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
86 settings_layout->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget)); |
| 46 | 87 |
| 88 QWidget* sg_anime_list_content = new QWidget(settings_widget); | |
| 89 | |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
90 constexpr int LAYOUT_HORIZ_SPACING = 25; |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
91 constexpr int LAYOUT_VERT_SPACING = 5; |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
92 constexpr int LAYOUT_ITEM_WIDTH = 175; |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
93 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
94 QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
95 al_layout->setSpacing(LAYOUT_VERT_SPACING); |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
96 al_layout->setContentsMargins(12, 0, 0, 0); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
97 |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
98 const auto CREATE_SECTION = [](QWidget* parent, std::function<void(QWidget*, QGridLayout*)> x) { |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
99 QWidget* section = new QWidget(parent); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
100 QGridLayout* layout = new QGridLayout(section); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
101 layout->setHorizontalSpacing(LAYOUT_HORIZ_SPACING); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
102 layout->setVerticalSpacing(LAYOUT_VERT_SPACING); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
103 layout->setContentsMargins(0, 0, 0, 0); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
104 x(section, layout); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
105 parent->layout()->addWidget(section); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
106 }; |
| 64 | 107 |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
108 const auto GRID_ADD_STRETCH = [](QGridLayout* layout) { |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
109 layout->setRowStretch(layout->rowCount(), 1); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
110 layout->setColumnStretch(layout->columnCount(), 1); |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
111 }; |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
112 |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
113 CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
114 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); |
| 46 | 115 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
116 QSpinBox* spin_box = new QSpinBox(section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
117 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _progress = i; }); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
118 spin_box->setRange(0, anime.GetEpisodes()); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
119 spin_box->setSingleStep(1); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
120 spin_box->setValue(_progress = anime.GetUserProgress()); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
121 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
122 layout->addWidget(spin_box, 1, 0); |
| 46 | 123 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
124 layout->addWidget(new QLabel(tr(" "), section), 0, 1); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
125 |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
126 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
127 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
128 [this](int state) { _rewatching = (state == Qt::Checked); }); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
129 checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked : Qt::Unchecked); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
130 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
131 layout->addWidget(checkbox, 1, 1); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
132 GRID_ADD_STRETCH(layout); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
133 }); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
134 |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
135 CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ |
| 46 | 136 /* Status & score section */ |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
137 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); |
| 46 | 138 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
139 /* FIXME: this sucks */ |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
140 QStringList string_list; |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
141 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
142 string_list.append(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i]))); |
| 46 | 143 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
144 QComboBox* combo_box = new QComboBox(section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
145 combo_box->addItems(string_list); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
146 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
147 [this](int i) { _status = Anime::ListStatuses[i]; }); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
148 combo_box->setCurrentIndex(static_cast<int>(_status = anime.GetUserStatus()) - 1); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
149 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
150 layout->addWidget(combo_box, 1, 0); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
151 |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
152 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); |
| 46 | 153 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
154 QSpinBox* spin_box = new QSpinBox(section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
155 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _score = i; }); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
156 spin_box->setRange(0, 100); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
157 spin_box->setSingleStep(5); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
158 spin_box->setValue(_score = anime.GetUserScore()); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
159 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
160 layout->addWidget(spin_box, 1, 1); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
161 GRID_ADD_STRETCH(layout); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
162 }); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
163 |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
164 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
165 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); |
| 46 | 166 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
167 QLineEdit* line_edit = new QLineEdit(section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
168 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
169 /* this sucks but I don't really want to implement anything smarter :) */ |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
170 _notes = Strings::ToUtf8String(text); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
171 }); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
172 line_edit->setText(Strings::ToQString(_notes = anime.GetUserNotes())); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
173 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
174 layout->addWidget(line_edit, 1, 0); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
175 }); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
176 |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
177 CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
178 /* Dates section */ |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
179 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
180 |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
181 OptionalDate* date = new OptionalDate(true, section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
182 connect(date, &OptionalDate::DataChanged, this, |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
183 [this](bool enabled, Date date) { _started = (enabled) ? date : Date(); }); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
184 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
185 _started = anime.GetUserDateStarted(); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
186 if (!_started.IsValid()) { |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
187 date->SetEnabled(false); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
188 _started = anime.GetAirDate(); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
189 } |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
190 date->SetDate(_started); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
191 layout->addWidget(date, 1, 0); |
| 46 | 192 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
193 layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
194 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
195 date = new OptionalDate(true, section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
196 connect(date, &OptionalDate::DataChanged, this, |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
197 [this](bool enabled, Date date) { _completed = (enabled) ? date : Date(); }); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
198 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
199 _completed = anime.GetUserDateCompleted(); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
200 if (!_completed.IsValid()) { |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
201 date->SetEnabled(false); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
202 _completed = anime.GetAirDate(); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
203 } |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
204 date->SetDate(_completed); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
205 layout->addWidget(date, 1, 1); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
206 GRID_ADD_STRETCH(layout); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
207 }); |
| 46 | 208 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
209 settings_layout->addWidget(sg_anime_list_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
210 |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
211 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); |
| 46 | 212 |
| 213 QWidget* sg_local_content = new QWidget(settings_widget); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
214 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
215 sg_local_layout->setSpacing(5); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
216 sg_local_layout->setContentsMargins(12, 0, 0, 0); |
| 46 | 217 |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
218 CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
|
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
219 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); |
| 46 | 220 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
221 QLineEdit* line_edit = new QLineEdit("", section); |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
222 line_edit->setPlaceholderText( |
|
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
223 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
224 layout->addWidget(line_edit, 1, 0); |
| 46 | 225 |
|
87
4aef97f4d998
information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents:
86
diff
changeset
|
226 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); |
|
88
1b19d80b3f8c
dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents:
87
diff
changeset
|
227 layout->addWidget(checkbox, 2, 0); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
228 }); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
229 #undef CREATE_SECTION |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
230 #undef CREATE_FULL_WIDTH_SECTION |
| 46 | 231 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
232 settings_layout->addWidget(sg_local_content); |
|
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
233 settings_layout->addStretch(); |
| 9 | 234 |
| 51 | 235 tabbed_widget->addTab(main_information_widget, tr("Main information")); |
| 236 tabbed_widget->addTab(settings_widget, tr("My list and settings")); | |
| 9 | 237 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
238 QVBoxLayout* main_layout = new QVBoxLayout(main_widget); |
| 9 | 239 main_layout->addWidget(anime_title); |
| 240 main_layout->addWidget(tabbed_widget); | |
| 62 | 241 main_layout->setContentsMargins(0, 0, 0, 0); |
| 86 | 242 main_layout->setSpacing(12); |
| 9 | 243 |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
244 QHBoxLayout* layout = new QHBoxLayout(widget); |
| 9 | 245 layout->addWidget(sidebar); |
| 246 layout->addWidget(main_widget); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
247 layout->setSpacing(12); |
| 9 | 248 |
| 249 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | |
| 83 | 250 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept, &anime] { |
| 251 SaveData(anime); | |
| 9 | 252 accept(); |
| 253 QDialog::accept(); | |
| 254 }); | |
| 255 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
| 256 | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
257 QVBoxLayout* buttons_layout = new QVBoxLayout(this); |
| 9 | 258 buttons_layout->addWidget(widget); |
| 259 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom); | |
| 260 } | |
| 261 | |
| 262 #include "gui/dialog/moc_information.cpp" |
