Skip to content

Commit edd9823

Browse files
authored
feat(sidebar): new filters, grid/list view toggle, and code cleanup (#1751)
* add new sidebar filter * hide magicbutton
1 parent 9d84d21 commit edd9823

39 files changed

+1063
-627
lines changed

core/Enum.vala

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -92,115 +92,6 @@ public enum ProjectIconStyle {
9292
}
9393
}
9494

95-
public enum FilterType {
96-
INBOX = 0,
97-
TODAY = 1,
98-
SCHEDULED = 2,
99-
PINBOARD = 3,
100-
LABELS = 4,
101-
COMPLETED = 5;
102-
103-
public string to_string () {
104-
switch (this) {
105-
case INBOX:
106-
return "inbox";
107-
108-
case TODAY:
109-
return "today";
110-
111-
case SCHEDULED:
112-
return "scheduled";
113-
114-
case PINBOARD:
115-
return "pinboard";
116-
117-
case LABELS:
118-
return "labels";
119-
120-
case COMPLETED:
121-
return "completed";
122-
123-
default:
124-
assert_not_reached ();
125-
}
126-
}
127-
128-
public string get_name () {
129-
switch (this) {
130-
case INBOX:
131-
return _("Inbox");
132-
133-
case TODAY:
134-
return _("Today");
135-
136-
case SCHEDULED:
137-
return _("Scheduled");
138-
139-
case PINBOARD:
140-
return _("Pinboard");
141-
142-
case LABELS:
143-
return _("Labels");
144-
145-
case COMPLETED:
146-
return _("Completed");
147-
148-
default:
149-
assert_not_reached ();
150-
}
151-
}
152-
153-
public string get_icon () {
154-
switch (this) {
155-
case INBOX:
156-
return "mailbox-symbolic";
157-
158-
case TODAY:
159-
return "star-outline-thick-symbolic";
160-
161-
case SCHEDULED:
162-
return "month-symbolic";
163-
164-
case PINBOARD:
165-
return "pin-symbolic";
166-
167-
case LABELS:
168-
return "tag-outline-symbolic";
169-
170-
case COMPLETED:
171-
return "check-round-outline-symbolic";
172-
173-
default:
174-
assert_not_reached ();
175-
}
176-
}
177-
178-
public string get_color (bool dark = Services.Settings.get_default ().settings.get_boolean ("dark-mode")) {
179-
switch (this) {
180-
case INBOX:
181-
return dark ? "#99c1f1" : "#3584e4";
182-
183-
case TODAY:
184-
return "#33d17a";
185-
186-
case SCHEDULED:
187-
return dark ? "#dc8add" : "#9141ac";
188-
189-
case PINBOARD:
190-
return dark ? "#f66151" : "#ed333b";
191-
192-
case LABELS:
193-
return dark ? "#cdab8f" : "#986a44";
194-
195-
case COMPLETED:
196-
return dark ? "#ffbe6f" : "#ff7800";
197-
198-
default:
199-
assert_not_reached ();
200-
}
201-
}
202-
}
203-
20495
public enum SourceType {
20596
NONE,
20697
LOCAL,
@@ -254,8 +145,7 @@ public enum PaneType {
254145
FILTER,
255146
FAVORITE,
256147
PROJECT,
257-
LABEL,
258-
TASKLIST
148+
LABEL
259149
}
260150

261151
public enum LoadingButtonType {

core/Objects/BaseObject.vala

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Objects.BaseObject : GLib.Object {
2424
public string name { get; set; default = ""; }
2525
public string keywords { get; set; default = ""; }
2626
public string icon_name { get; set; default = ""; }
27+
public string color { get; set; default = ""; }
2728

2829
public signal void deleted ();
2930
public signal void updated (string update_id = "");
@@ -73,6 +74,7 @@ public class Objects.BaseObject : GLib.Object {
7374

7475
public signal void loading_change ();
7576
public signal void sensitive_change ();
77+
public signal void count_updated ();
7678

7779
public string view_id { get; set; default = ""; }
7880

@@ -223,6 +225,32 @@ public class Objects.BaseObject : GLib.Object {
223225
}
224226
}
225227

228+
public int ? _item_count = null;
229+
public int item_count {
230+
get {
231+
if (_item_count == null) {
232+
_item_count = update_count ();
233+
}
234+
235+
return _item_count;
236+
}
237+
238+
set {
239+
_item_count = value;
240+
}
241+
}
242+
243+
public double ? _percentage = null;
244+
public double percentage {
245+
get {
246+
if (_percentage == null) {
247+
_percentage = update_percentage ();
248+
}
249+
250+
return _percentage;
251+
}
252+
}
253+
226254
public virtual string get_update_json (string uuid, string ? temp_id = null) {
227255
return "";
228256
}
@@ -267,4 +295,18 @@ public class Objects.BaseObject : GLib.Object {
267295

268296
return null;
269297
}
298+
299+
public virtual int update_count () {
300+
return 0;
301+
}
302+
303+
public virtual double update_percentage () {
304+
return 0.0;
305+
}
306+
307+
public virtual void count_update () { }
308+
309+
public virtual string theme_color () {
310+
return color;
311+
}
270312
}

core/Objects/Filters/AllItems.vala

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,46 @@ public class Objects.Filters.AllItems : Objects.BaseObject {
2828

2929
return _instance;
3030
}
31-
31+
3232
construct {
3333
name = _("All Tasks");
3434
keywords = "%s;%s".printf (_("all tasks"), _("all"));
3535
icon_name = "check-round-outline-symbolic";
3636
view_id = "all-items-view";
37+
color = Services.Settings.get_default ().settings.get_boolean ("dark-mode") ? "#99c1f1" : "#3584e4";
38+
39+
Services.Store.instance ().item_added.connect (() => {
40+
count_update ();
41+
});
42+
43+
Services.Store.instance ().item_deleted.connect (() => {
44+
count_update ();
45+
});
46+
47+
Services.Store.instance ().item_archived.connect (() => {
48+
count_update ();
49+
});
50+
51+
Services.Store.instance ().item_unarchived.connect (() => {
52+
count_update ();
53+
});
54+
55+
Services.Store.instance ().item_updated.connect (() => {
56+
count_update ();
57+
});
58+
}
59+
60+
public override int update_count () {
61+
return Services.Store.instance ().get_items_no_parent (false).size;
62+
}
63+
64+
public override void count_update () {
65+
_item_count = update_count ();
66+
67+
count_updated ();
68+
}
69+
70+
public override string theme_color () {
71+
return Services.Settings.get_default ().get_boolean ("dark-mode") ? "#99c1f1" : "#3584e4";
3772
}
3873
}

core/Objects/Filters/Anytime.vala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,40 @@ public class Objects.Filters.Anytime : Objects.BaseObject {
3434
keywords = "%s;%s;%s".printf (_("anytime"), _("filters"), _("no date"));
3535
icon_name = "grid-large-symbolic";
3636
view_id = "anytime-view";
37+
color = Services.Settings.get_default ().settings.get_boolean ("dark-mode") ? "#dc8add" : "#9141ac";
38+
39+
Services.Store.instance ().item_added.connect (() => {
40+
count_update ();
41+
});
42+
43+
Services.Store.instance ().item_deleted.connect (() => {
44+
count_update ();
45+
});
46+
47+
Services.Store.instance ().item_archived.connect (() => {
48+
count_update ();
49+
});
50+
51+
Services.Store.instance ().item_unarchived.connect (() => {
52+
count_update ();
53+
});
54+
55+
Services.Store.instance ().item_updated.connect (() => {
56+
count_update ();
57+
});
58+
}
59+
60+
public override int update_count () {
61+
return Services.Store.instance ().get_items_no_date (false).size;
62+
}
63+
64+
public override void count_update () {
65+
_item_count = update_count ();
66+
67+
count_updated ();
68+
}
69+
70+
public override string theme_color () {
71+
return Services.Settings.get_default ().settings.get_boolean ("dark-mode") ? "#dc8add" : "#9141ac";
3772
}
3873
}

core/Objects/Filters/Completed.vala

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,44 @@ public class Objects.Filters.Completed : Objects.BaseObject {
2929
return _instance;
3030
}
3131

32-
int ? _count = null;
33-
public int count {
34-
get {
35-
if (_count == null) {
36-
_count = Services.Store.instance ().get_items_completed ().size;
37-
}
38-
39-
return _count;
40-
}
41-
42-
set {
43-
_count = value;
44-
}
45-
}
46-
47-
public signal void count_updated ();
48-
4932
construct {
5033
name = _("Completed");
5134
keywords = "%s;%s;%s".printf (_("completed"), _("filters"), _("logbook"));
5235
icon_name = "check-round-outline-symbolic";
53-
view_id = FilterType.COMPLETED.to_string ();
36+
view_id = "completed";
37+
color = Services.Settings.get_default ().settings.get_boolean ("dark-mode") ? "#ffbe6f" : "#ff7800";
5438

5539
Services.Store.instance ().item_added.connect (() => {
56-
_count = Services.Store.instance ().get_items_completed ().size;
57-
count_updated ();
40+
count_update ();
5841
});
5942

6043
Services.Store.instance ().item_deleted.connect (() => {
61-
_count = Services.Store.instance ().get_items_completed ().size;
62-
count_updated ();
44+
count_update ();
6345
});
6446

6547
Services.Store.instance ().item_updated.connect (() => {
66-
_count = Services.Store.instance ().get_items_completed ().size;
67-
count_updated ();
48+
count_update ();
6849
});
6950

7051
Services.Store.instance ().item_archived.connect (() => {
71-
_count = Services.Store.instance ().get_items_completed ().size;
72-
count_updated ();
52+
count_update ();
7353
});
7454

7555
Services.Store.instance ().item_unarchived.connect (() => {
76-
_count = Services.Store.instance ().get_items_completed ().size;
77-
count_updated ();
56+
count_update ();
7857
});
7958
}
59+
60+
public override int update_count () {
61+
return Services.Store.instance ().get_items_completed ().size;
62+
}
63+
64+
public override void count_update () {
65+
_item_count = update_count ();
66+
count_updated ();
67+
}
68+
69+
public override string theme_color () {
70+
return Services.Settings.get_default ().settings.get_boolean ("dark-mode") ? "#ffbe6f" : "#ff7800";
71+
}
8072
}

0 commit comments

Comments
 (0)