Skip to content

Commit

Permalink
fix #677
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed May 29, 2024
1 parent d79a585 commit d858519
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 41 deletions.
38 changes: 38 additions & 0 deletions core/Objects/Filters/AllItems.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Alain M. <[email protected]>
*/

public class Objects.Filters.AllItems : Objects.BaseObject {
private static AllItems? _instance;
public static AllItems get_default () {
if (_instance == null) {
_instance = new AllItems ();
}

return _instance;
}

construct {
name = _("All Tasks");
keywords = "%s;%s".printf (_("all tasks"), _("all"));
icon_name = "check-round-outline-symbolic";
view_id = "all-items-view";
}
}
3 changes: 2 additions & 1 deletion core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ core_files = files(
'Objects/Filters/Anytime.vala',
'Objects/Filters/Repeating.vala',
'Objects/Filters/Unlabeled.vala',
'Objects/Filters/FilterItem.vala'
'Objects/Filters/FilterItem.vala',
'Objects/Filters/AllItems.vala'
)

core_deps = [
Expand Down
4 changes: 2 additions & 2 deletions data/io.github.alainm23.planify.appdata.xml.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
<release version="4.7.6" date="2024-05-20">
<description translate="no">
<ul>
<li>Fixed bug when editing a label.</li>
<li>Fixed bug when downloading a backup.</li>
<li>Fixed bug when editing a label</li>
<li>Fixed bug when downloading a backup</li>
<li>Updated Translations for Hindi</li>
</ul>
</description>
Expand Down
3 changes: 2 additions & 1 deletion src/Dialogs/QuickFind/QuickFind.vala
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public class Dialogs.QuickFind.QuickFind : Adw.Dialog {
Objects.Filters.Tomorrow.get_default (),
Objects.Filters.Anytime.get_default (),
Objects.Filters.Repeating.get_default (),
Objects.Filters.Unlabeled.get_default ()
Objects.Filters.Unlabeled.get_default (),
Objects.Filters.AllItems.get_default ()
};

foreach (Objects.BaseObject object in filters) {
Expand Down
3 changes: 2 additions & 1 deletion src/Dialogs/QuickFind/QuickFindItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public class Dialogs.QuickFind.QuickFindItem : Gtk.ListBoxRow {
base_object is Objects.Filters.Completed || base_object is Objects.Filters.Tomorrow ||
base_object is Objects.Filters.Labels || base_object is Objects.Filters.Scheduled ||
base_object is Objects.Filters.Pinboard || base_object is Objects.Filters.Anytime ||
base_object is Objects.Filters.Repeating || base_object is Objects.Filters.Unlabeled) {
base_object is Objects.Filters.Repeating || base_object is Objects.Filters.Unlabeled ||
base_object is Objects.Filters.AllItems) {
var filter_icon = new Gtk.Image.from_icon_name (base_object.icon_name) {
valign = Gtk.Align.CENTER,
pixel_size = 16
Expand Down
57 changes: 35 additions & 22 deletions src/Layouts/ItemRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public class Layouts.ItemRow : Layouts.ItemBase {

private Widgets.LoadingButton hide_loading_button;
private Widgets.Markdown.Buffer current_buffer;
private Widgets.Markdown.EditView markdown_edit_view;
private Widgets.Markdown.EditView markdown_edit_view = null;
private Gtk.Revealer markdown_revealer;
private Widgets.ItemLabels item_labels;
private Widgets.ScheduleButton schedule_button;
private Widgets.LabelsSummary labels_summary;
Expand Down Expand Up @@ -97,6 +98,10 @@ public class Layouts.ItemRow : Layouts.ItemBase {
itemrow_box.add_css_class ("card");
itemrow_box.add_css_class ("card-selected");

if (markdown_edit_view == null) {
build_markdown_edit_view ();
}

detail_revealer.reveal_child = true;
content_label_revealer.reveal_child = false;
content_entry_revealer.reveal_child = true;
Expand Down Expand Up @@ -389,15 +394,7 @@ public class Layouts.ItemRow : Layouts.ItemBase {
};

current_buffer = new Widgets.Markdown.Buffer ();

markdown_edit_view = new Widgets.Markdown.EditView () {
left_margin = 24,
right_margin = 6,
top_margin = 3,
bottom_margin = 12
};

markdown_edit_view.buffer = current_buffer;
markdown_revealer = new Gtk.Revealer ();

item_labels = new Widgets.ItemLabels (item) {
margin_start = 24,
Expand Down Expand Up @@ -503,7 +500,7 @@ public class Layouts.ItemRow : Layouts.ItemBase {
});

var details_grid = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
details_grid.append (markdown_edit_view);
details_grid.append (markdown_revealer);
details_grid.append (item_labels);
details_grid.append (action_box);

Expand Down Expand Up @@ -618,13 +615,6 @@ public class Layouts.ItemRow : Layouts.ItemBase {
edit = item.id == item_id;
});

var description_gesture_click = new Gtk.GestureClick ();
markdown_edit_view.add_controller (description_gesture_click);
description_gesture_click.released.connect ((n_press, x, y) => {
description_gesture_click.set_state (Gtk.EventSequenceState.CLAIMED);
markdown_edit_view.view_focus ();
});

var content_controller_key = new Gtk.EventControllerKey ();
content_textview.add_controller (content_controller_key);
content_controller_key.key_pressed.connect ((keyval, keycode, state) => {
Expand All @@ -647,10 +637,6 @@ public class Layouts.ItemRow : Layouts.ItemBase {
}
});

markdown_edit_view.escape.connect (() => {
edit = false;
});

var checked_button_gesture = new Gtk.GestureClick ();
checked_button.add_controller (checked_button_gesture);
checked_button_gesture.pressed.connect (() => {
Expand Down Expand Up @@ -1770,6 +1756,8 @@ public class Layouts.ItemRow : Layouts.ItemBase {
public void disable_drag_and_drop () {
drag_enabled = false;
_disable_drag_and_drop ();

subitems.disable_drag_and_drop ();
}

private void _disable_drag_and_drop () {
Expand Down Expand Up @@ -1812,4 +1800,29 @@ public class Layouts.ItemRow : Layouts.ItemBase {
row_index++;
} while (item_row != null);
}

private void build_markdown_edit_view () {
markdown_edit_view = new Widgets.Markdown.EditView () {
left_margin = 24,
right_margin = 6,
top_margin = 3,
bottom_margin = 12
};

markdown_edit_view.buffer = current_buffer;

markdown_revealer.child = markdown_edit_view;
markdown_revealer.reveal_child = true;

var description_gesture_click = new Gtk.GestureClick ();
markdown_edit_view.add_controller (description_gesture_click);
description_gesture_click.released.connect ((n_press, x, y) => {
description_gesture_click.set_state (Gtk.EventSequenceState.CLAIMED);
markdown_edit_view.view_focus ();
});

markdown_edit_view.escape.connect (() => {
edit = false;
});
}
}
2 changes: 2 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ public class MainWindow : Adw.ApplicationWindow {
add_filter_view (Objects.Filters.Repeating.get_default ());
} else if (id == "unlabeled-view") {
add_filter_view (Objects.Filters.Unlabeled.get_default ());
} else if (id == "all-items-view") {
add_filter_view (Objects.Filters.AllItems.get_default ());
}
} else if (pane_type == PaneType.LABEL) {
add_label_view (id);
Expand Down
19 changes: 18 additions & 1 deletion src/Views/Filter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public class Views.Filter : Adw.Bin {
if (items.has_key (item.id)) {
items[item.id].update_request ();
}

listbox.invalidate_sort ();
});

magic_button.clicked.connect (() => {
Expand Down Expand Up @@ -224,6 +226,12 @@ public class Views.Filter : Adw.Bin {
listbox.set_header_func (header_project_function);
listbox_content.margin_top = 12;
magic_button.visible = true;
} else if (filter is Objects.Filters.AllItems) {
headerbar.title = _("All Tasks");
listbox.set_sort_func (sort_project_function);
listbox.set_header_func (header_project_function);
listbox_content.margin_top = 12;
magic_button.visible = true;
}

view_setting_revealer.reveal_child = filter is Objects.Filters.Completed;
Expand Down Expand Up @@ -265,6 +273,10 @@ public class Views.Filter : Adw.Bin {
foreach (Objects.Item item in Services.Database.get_default ().get_items_unlabeled (false)) {
add_item (item);
}
} else if (filter is Objects.Filters.AllItems) {
foreach (Objects.Item item in Services.Database.get_default ().items) {
add_item (item);
}
}
}

Expand Down Expand Up @@ -306,6 +318,10 @@ public class Views.Filter : Adw.Bin {
if (!items.has_key (item.id) && item.labels.size <= 0 && insert) {
add_item (item);
}
} else if (filter is Objects.Filters.AllItems) {
if (!items.has_key (item.id) && insert) {
add_item (item);
}
}

validate_placeholder ();
Expand Down Expand Up @@ -389,7 +405,8 @@ public class Views.Filter : Adw.Bin {
private void valid_checked_item (Objects.Item item, bool old_checked) {
if (filter is Objects.Filters.Priority || filter is Objects.Filters.Tomorrow ||
filter is Objects.Filters.Pinboard || filter is Objects.Filters.Anytime ||
filter is Objects.Filters.Repeating || filter is Objects.Filters.Unlabeled
filter is Objects.Filters.Repeating || filter is Objects.Filters.Unlabeled ||
filter is Objects.Filters.AllItems
) {
if (!old_checked) {
if (items.has_key (item.id) && item.completed) {
Expand Down
49 changes: 36 additions & 13 deletions src/Views/Project/Project.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ public class Views.Project : Adw.Bin {
private Adw.ToolbarView toolbar_view;
private Widgets.ContextMenu.MenuItem show_completed_item;
private Widgets.ContextMenu.MenuItem delete_all_completed;
private Widgets.ContextMenu.MenuItem expand_all_item;
private Widgets.ContextMenu.MenuItem collapse_all_item;
private Widgets.ContextMenu.MenuCheckPicker priority_filter;
private Widgets.ContextMenu.MenuPicker due_date_item;
private Widgets.MultiSelectToolbar multiselect_toolbar;
private Gtk.Revealer indicator_revealer;

public ProjectViewStyle view_style {
get {
return project.backend_type == BackendType.CALDAV ? ProjectViewStyle.LIST : project.view_style;
}
}

public Project (Objects.Project project) {
Object (
project: project
Expand Down Expand Up @@ -132,7 +140,7 @@ public class Views.Project : Adw.Bin {
toolbar_view.content = content_overlay;

child = toolbar_view;
update_project_view (project.backend_type == BackendType.CALDAV ? ProjectViewStyle.LIST : project.view_style);
update_project_view ();
check_default_filters ();
show ();

Expand Down Expand Up @@ -181,6 +189,13 @@ public class Views.Project : Adw.Bin {

check_default_filters ();
});

project.view_style_changed.connect (() => {
update_project_view ();

expand_all_item.visible = view_style == ProjectViewStyle.LIST;
collapse_all_item.visible = view_style == ProjectViewStyle.LIST;
});
}

private void check_default_filters () {
Expand All @@ -201,7 +216,7 @@ public class Views.Project : Adw.Bin {
indicator_revealer.reveal_child = !defaults;
}

private void update_project_view (ProjectViewStyle view_style) {
private void update_project_view () {
view_stack.visible_child_name = "loading";

Timeout.add (275, () => {
Expand All @@ -222,8 +237,6 @@ public class Views.Project : Adw.Bin {
}

view_stack.set_visible_child_name (view_style.to_string ());
project.view_style = view_style;
project.update_local ();

return GLib.Source.REMOVE;
});
Expand All @@ -234,15 +247,15 @@ public class Views.Project : Adw.Bin {
return;
}

if (project.view_style == ProjectViewStyle.LIST) {
if (view_style == ProjectViewStyle.LIST) {
Views.List? list_view;
list_view = (Views.List) view_stack.get_child_by_name (project.view_style.to_string ());
list_view = (Views.List) view_stack.get_child_by_name (view_style.to_string ());
if (list_view != null) {
list_view.prepare_new_item (content);
}
} else {
Views.Board? board_view;
board_view = (Views.Board) view_stack.get_child_by_name (project.view_style.to_string ());
board_view = (Views.Board) view_stack.get_child_by_name (view_style.to_string ());
if (board_view != null) {
board_view.prepare_new_item (content);
}
Expand All @@ -259,8 +272,12 @@ public class Views.Project : Adw.Bin {

var select_item = new Widgets.ContextMenu.MenuItem (_("Select"), "list-large-symbolic");
var paste_item = new Widgets.ContextMenu.MenuItem (_("Paste"), "tabs-stack-symbolic");
var expand_all_item = new Widgets.ContextMenu.MenuItem (_("Expand All"), "size-vertically-symbolic");
var collapse_all_item = new Widgets.ContextMenu.MenuItem (_("Collapse All"), "size-vertically-symbolic");
expand_all_item = new Widgets.ContextMenu.MenuItem (_("Expand All"), "size-vertically-symbolic") {
visible = view_style == ProjectViewStyle.LIST
};
collapse_all_item = new Widgets.ContextMenu.MenuItem (_("Collapse All"), "size-vertically-symbolic") {
visible = view_style == ProjectViewStyle.LIST
};
var archive_item = new Widgets.ContextMenu.MenuItem (_("Archive"), "shoe-box-symbolic");
var delete_item = new Widgets.ContextMenu.MenuItem (_("Delete Project"), "user-trash-symbolic");
delete_item.add_css_class ("menu-item-danger");
Expand Down Expand Up @@ -399,7 +416,7 @@ public class Views.Project : Adw.Bin {

var list_button = new Gtk.ToggleButton () {
child = list_box,
active = project.view_style == ProjectViewStyle.LIST
active = view_style == ProjectViewStyle.LIST
};

var board_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
Expand All @@ -415,7 +432,7 @@ public class Views.Project : Adw.Bin {
var board_button = new Gtk.ToggleButton () {
group = list_button,
child = board_box,
active = project.view_style == ProjectViewStyle.BOARD
active = view_style == ProjectViewStyle.BOARD
};

var view_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
Expand Down Expand Up @@ -552,11 +569,17 @@ public class Views.Project : Adw.Bin {
});

list_button.toggled.connect (() => {
update_project_view (ProjectViewStyle.LIST);
popover.popdown ();

project.view_style = ProjectViewStyle.LIST;
project.update_local ();
});

board_button.toggled.connect (() => {
update_project_view (ProjectViewStyle.BOARD);
popover.popdown ();

project.view_style = ProjectViewStyle.BOARD;
project.update_local ();
});

project.sort_order_changed.connect (() => {
Expand Down
6 changes: 6 additions & 0 deletions src/Widgets/SubItems.vala
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,10 @@ public class Widgets.SubItems : Adw.Bin {

signals_map.clear ();
}

public void disable_drag_and_drop () {
foreach (Layouts.ItemBase row in items.values) {
((Layouts.ItemRow) row).disable_drag_and_drop ();
}
}
}

0 comments on commit d858519

Please sign in to comment.