annotate src/gui/dialog/information.cc @ 105:6d8da6e64d61

theme: add dark stylesheet, make it actually usable win32: make the titlebar black where available
author Paper <mrpapersonic@gmail.com>
date Sun, 05 Nov 2023 03:54:26 -0500
parents e6fab256ddc4
children 2004b41d4a59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/dialog/information.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include "core/strings.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include "gui/pages/anime_list.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include "gui/translate/anime.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
7 #include "gui/widgets/anime_info.h"
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
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
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
10 #include "gui/widgets/text.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #include "gui/window.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
12 #include <QCheckBox>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 #include <QDebug>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 #include <QDialogButtonBox>
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
17 #include <QLabel>
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
18 #include <QLineEdit>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 #include <QPlainTextEdit>
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
20 #include <QSpinBox>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
21 #include <QStringList>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 #include <QTextStream>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 #include <QVBoxLayout>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 #include <functional>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
26 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list,
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
27 which sucks. Think of a better way to implement this later. */
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 void InformationDialog::SaveData(Anime::Anime& anime) {
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
29 anime.SetUserProgress(_progress);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
30 anime.SetUserScore(_score);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
31 anime.SetUserIsRewatching(_rewatching);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
32 anime.SetUserStatus(_status);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
33 anime.SetUserNotes(_notes);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
34 anime.SetUserDateStarted(_started);
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
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
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
38 InformationDialog::InformationDialog(Anime::Anime& anime, std::function<void()> accept, QWidget* parent)
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
39 : QDialog(parent) {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 setFixedSize(842, 613);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 setWindowTitle(tr("Anime Information"));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
43
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
44 {
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 89
diff changeset
45 QPalette pal;
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
46 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
47 setPalette(pal);
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
48 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 QWidget* widget = new QWidget(this);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 /* "sidebar", includes... just the anime image :) */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 /* main widget */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 QWidget* main_widget = new QWidget(widget);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
62
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 /* anime title header text */
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
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
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 /* tabbed widget */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 QTabWidget* tabbed_widget = new QTabWidget(main_widget);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 /* main info tab */
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
74 AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 QWidget* settings_widget = new QWidget(tabbed_widget);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
77 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
78
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
79 QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget);
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
80 settings_layout->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget));
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
81
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
82 QWidget* sg_anime_list_content = new QWidget(settings_widget);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
83
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
84 constexpr int LAYOUT_HORIZ_SPACING = 25;
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
85 constexpr int LAYOUT_VERT_SPACING = 5;
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
86 constexpr int LAYOUT_ITEM_WIDTH = 175;
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
87
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
88 QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content);
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
89 al_layout->setSpacing(LAYOUT_VERT_SPACING);
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
90 al_layout->setContentsMargins(12, 0, 0, 0);
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
91
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
92 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
93 QWidget* section = new QWidget(parent);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
94 QGridLayout* layout = new QGridLayout(section);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
95 layout->setHorizontalSpacing(LAYOUT_HORIZ_SPACING);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
96 layout->setVerticalSpacing(LAYOUT_VERT_SPACING);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
97 layout->setContentsMargins(0, 0, 0, 0);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
98 x(section, layout);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
99 parent->layout()->addWidget(section);
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
100 };
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
101
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
102 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
103 /* Episodes watched... */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
104 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
105
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
106 QSpinBox* spin_box = new QSpinBox(section);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
107 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
108 spin_box->setRange(0, anime.GetEpisodes());
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
109 spin_box->setSingleStep(1);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
110 spin_box->setValue(_progress = anime.GetUserProgress());
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
111 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH);
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
112 layout->addWidget(spin_box, 1, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
113
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
114 /* Rewatching? */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
115 QCheckBox* checkbox = new QCheckBox(tr("Rewatching"));
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
116 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this,
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
117 [this](int state) { _rewatching = (state == Qt::Checked); });
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
118 checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked : Qt::Unchecked);
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
119 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH);
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
120 layout->addWidget(checkbox, 1, 1);
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
121 layout->setColumnStretch(layout->columnCount(), 1);
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
122 });
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
123
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
124 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
125 /* Status */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
126 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
127
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
128 QComboBox* combo_box = new QComboBox(section);
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
129
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
130 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++)
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
131 combo_box->addItem(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])), static_cast<int>(Anime::ListStatuses[i]));
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
132
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
133 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this, combo_box](int) {
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
134 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt());
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
135 });
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
136 /* this should NEVER, EVER, be NOT_IN_LIST */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
137 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
138 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH);
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
139 layout->addWidget(combo_box, 1, 0);
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
140
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
141 /* Score */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
142 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
143
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
144 QSpinBox* spin_box = new QSpinBox(section);
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
145 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) {
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
146 _score = i;
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
147 });
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
148 spin_box->setRange(0, 100);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
149 spin_box->setSingleStep(5);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
150 spin_box->setValue(_score = anime.GetUserScore());
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
151 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH);
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
152 layout->addWidget(spin_box, 1, 1);
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
153 layout->setColumnStretch(layout->columnCount(), 1);
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
154 });
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
155
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
156 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
157 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
158
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
159 QLineEdit* line_edit = new QLineEdit(section);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
160 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) {
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
161 /* 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
162 _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
163 });
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
164 line_edit->setText(Strings::ToQString(_notes = anime.GetUserNotes()));
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
165 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
166 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
167 });
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
168
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
169 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
170 /* Started */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
171 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
172
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
173 OptionalDate* date = new OptionalDate(true, section);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
174 connect(date, &OptionalDate::DataChanged, this,
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
175 [this](bool enabled, Date date) { _started = enabled ? date : Date(); });
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
176 date->setFixedWidth(LAYOUT_ITEM_WIDTH);
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
177 _started = anime.GetUserDateStarted();
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
178 if (!_started.IsValid()) {
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
179 date->SetEnabled(false);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
180 _started = anime.GetAirDate();
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
181 }
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
182 date->SetDate(_started);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
183 layout->addWidget(date, 1, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
184
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
185 /* Completed */
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
186 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
187
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
188 date = new OptionalDate(true, section);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
189 connect(date, &OptionalDate::DataChanged, this,
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
190 [this](bool enabled, Date date) { _completed = enabled ? date : Date(); });
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
191 date->setFixedWidth(LAYOUT_ITEM_WIDTH);
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
192 _completed = anime.GetUserDateCompleted();
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
193 if (!_completed.IsValid()) {
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
194 date->SetEnabled(false);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
195 _completed = anime.GetAirDate();
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
196 }
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
197 date->SetDate(_completed);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
198 layout->addWidget(date, 1, 1);
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
199 layout->setColumnStretch(layout->columnCount(), 1);
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
200 });
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
201
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
202 settings_layout->addWidget(sg_anime_list_content);
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
203
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
204 /*
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
205 // commenting this out until it actually gets implemented :)
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
206
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
207 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget));
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
208
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
209 QWidget* sg_local_content = new QWidget(settings_widget);
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
210 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content);
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
211 sg_local_layout->setSpacing(5);
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
212 sg_local_layout->setContentsMargins(12, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
213
88
1b19d80b3f8c dialog/information.cc: fix QGridLayout :)
Paper <mrpapersonic@gmail.com>
parents: 87
diff changeset
214 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
215 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
216
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
217 QLineEdit* line_edit = new QLineEdit("", section);
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
218 line_edit->setPlaceholderText(
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
219 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
220 layout->addWidget(line_edit, 1, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
221
87
4aef97f4d998 information: use QGridLayout please...
Paper <mrpapersonic@gmail.com>
parents: 86
diff changeset
222 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
223 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
224 });
89
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
225
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
226 settings_layout->addWidget(sg_local_content);
e6fab256ddc4 dialog/info: make some stuff more sane
Paper <mrpapersonic@gmail.com>
parents: 88
diff changeset
227 */
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
228 #undef CREATE_SECTION
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
229 #undef CREATE_FULL_WIDTH_SECTION
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
230
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
231 settings_layout->addStretch();
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
232
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
233 tabbed_widget->addTab(main_information_widget, tr("Main information"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
234 tabbed_widget->addTab(settings_widget, tr("My list and settings"));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
236 QVBoxLayout* main_layout = new QVBoxLayout(main_widget);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
237 main_layout->addWidget(anime_title);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
238 main_layout->addWidget(tabbed_widget);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
239 main_layout->setContentsMargins(0, 0, 0, 0);
86
c912128af0eb *: various macos fixes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
240 main_layout->setSpacing(12);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
241
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
242 QHBoxLayout* layout = new QHBoxLayout(widget);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
243 layout->addWidget(sidebar);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
244 layout->addWidget(main_widget);
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
245 layout->setSpacing(12);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
246
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
247 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
248 connect(button_box, &QDialogButtonBox::accepted, this, [this, accept, &anime] {
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
249 SaveData(anime);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
250 accept();
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
251 QDialog::accept();
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
252 });
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
253 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
254
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
255 QVBoxLayout* buttons_layout = new QVBoxLayout(this);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
256 buttons_layout->addWidget(widget);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
257 buttons_layout->addWidget(button_box, 0, Qt::AlignBottom);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
258 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
259
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
260 #include "gui/dialog/moc_information.cpp"