annotate src/gui/widgets/optional_date.cc @ 118:39521c47c7a3

*: another huge megacommit, SORRY The torrents page works a lot better now Added the edit option to the anime list right click menu Vectorized currently playing files Available player and extensions are now loaded at runtime from files in (dotpath)/players.json and (dotpath)/extensions.json These paths are not permanent and will likely be moved to (dotpath)/recognition ... ... ...
author Paper <mrpapersonic@gmail.com>
date Tue, 07 Nov 2023 23:40:54 -0500
parents 9b2b41f83a5e
children 4d461ef7d424
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/widgets/optional_date.h"
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
2 #include "core/date.h"
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include <QCheckBox>
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include <QDateEdit>
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <QHBoxLayout>
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 OptionalDate::OptionalDate(QWidget* parent) {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 OptionalDate(false, parent);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 OptionalDate::OptionalDate(bool enabled, QWidget* parent) : QWidget(parent) {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 QHBoxLayout* layout = new QHBoxLayout(this);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
13 layout->setContentsMargins(0, 0, 0, 0);
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 _checkbox = new QCheckBox(this);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 _checkbox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
18 layout->addWidget(_checkbox, 0, Qt::AlignVCenter);
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 _dateedit = new QDateEdit(this);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 _dateedit->setDisplayFormat("yyyy-MM-dd");
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 _dateedit->setCalendarPopup(true);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 _dateedit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 layout->addWidget(_dateedit);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 SetEnabled(enabled);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
28 connect(_checkbox, &QCheckBox::stateChanged, this, [this](int state) {
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
29 SetEnabled(state == Qt::Checked);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
30 emit DataChanged(IsEnabled(), GetDate());
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
31 });
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
32 connect(_dateedit, &QDateEdit::dateChanged, this, [this](QDate) { emit DataChanged(IsEnabled(), GetDate()); });
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 void OptionalDate::SetEnabled(bool enabled) {
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
36 _checkbox->setCheckState(enabled ? Qt::Checked : Qt::Unchecked);
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 _dateedit->setEnabled(enabled);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 bool OptionalDate::IsEnabled() {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 return _dateedit->isEnabled();
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 void OptionalDate::SetDate(QDate date) {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 _dateedit->setDate(date);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
48 void OptionalDate::SetDate(Date date) {
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
49 if (!date.IsValid())
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
50 return;
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
51 SetDate(date.GetAsQDate());
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
52 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
53
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
54 Date OptionalDate::GetDate() {
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
55 return Date(_dateedit->date());
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
56 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
57
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 QDateEdit* OptionalDate::GetDateEdit() {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 return _dateedit;
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 QCheckBox* OptionalDate::GetCheckBox() {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 return _checkbox;
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
65
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
66 #include "gui/widgets/moc_optional_date.cpp"