Skip to content

Commit 15a598e

Browse files
committed
fix #1178 #1180
1 parent 941de34 commit 15a598e

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

core/QuickAdd.vala

+31-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Layouts.QuickAdd : Adw.Bin {
2020

2121
public bool ctrl_pressed { get; set; default = false; }
2222
public bool shift_pressed { get; set; default = false; }
23+
public bool create_more { get; set; default = Services.Settings.get_default ().settings.get_boolean ("quick-add-create-more"); }
2324

2425
public QuickAdd (bool is_window_quick_add = false) {
2526
Object (
@@ -215,7 +216,6 @@ public class Layouts.QuickAdd : Adw.Bin {
215216
return GLib.Source.REMOVE;
216217
});
217218

218-
content_entry.activate.connect (add_item);
219219
submit_button.clicked.connect (add_item);
220220

221221
project_picker_button.project_change.connect ((project) => {
@@ -259,6 +259,23 @@ public class Layouts.QuickAdd : Adw.Bin {
259259
return false;
260260
});
261261

262+
content_entry.activate.connect (() => {
263+
create_more = Services.Settings.get_default ().settings.get_boolean ("quick-add-create-more");
264+
add_item ();
265+
});
266+
267+
var content_controller_key = new Gtk.EventControllerKey ();
268+
content_entry.add_controller (content_controller_key);
269+
content_controller_key.key_pressed.connect ((keyval, keycode, state) => {
270+
if (keyval == 65293 && (ctrl_pressed || shift_pressed)) {
271+
create_more = true;
272+
add_item ();
273+
return false;
274+
}
275+
276+
return false;
277+
});
278+
262279
var description_controller_key = new Gtk.EventControllerKey ();
263280
description_textview.add_controller (description_controller_key);
264281
description_controller_key.key_pressed.connect ((keyval, keycode, state) => {
@@ -306,6 +323,10 @@ public class Layouts.QuickAdd : Adw.Bin {
306323
if (item.project.backend_type == BackendType.LOCAL) {
307324
item.id = Util.get_default ().generate_id ();
308325
add_item_db (item);
326+
327+
if (item.parent_id != "") {
328+
item.parent.collapsed = true;
329+
}
309330
} else if (item.project.backend_type == BackendType.TODOIST) {
310331
submit_button.is_loading = true;
311332
Services.Todoist.get_default ().add.begin (item, (obj, res) => {
@@ -315,6 +336,10 @@ public class Layouts.QuickAdd : Adw.Bin {
315336
if (response.status) {
316337
item.id = response.data;
317338
add_item_db (item);
339+
340+
if (item.parent_id != "") {
341+
item.parent.collapsed = true;
342+
}
318343
}
319344
});
320345
} else if (item.project.backend_type == BackendType.CALDAV) {
@@ -326,6 +351,10 @@ public class Layouts.QuickAdd : Adw.Bin {
326351

327352
if (response.status) {
328353
add_item_db (item);
354+
355+
if (item.parent_id != "") {
356+
item.parent.collapsed = true;
357+
}
329358
}
330359
});
331360
}
@@ -336,7 +365,7 @@ public class Layouts.QuickAdd : Adw.Bin {
336365
added_image.add_css_class ("fancy-turn-animation");
337366

338367
Timeout.add (750, () => {
339-
if (Services.Settings.get_default ().settings.get_boolean ("quick-add-create-more")) {
368+
if (create_more) {
340369
main_stack.visible_child_name = "main";
341370
added_image.remove_css_class ("fancy-turn-animation");
342371

src/Layouts/ItemRow.vala

+3-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ public class Layouts.ItemRow : Layouts.ItemBase {
736736
}
737737

738738
public void check_hide_subtask_button () {
739-
hide_subtask_revealer.reveal_child = subitems.has_children;
739+
if (!edit) {
740+
hide_subtask_revealer.reveal_child = subitems.has_children;
741+
}
740742
}
741743

742744
private void selected_toggled (bool active) {

src/MainWindow.vala

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class MainWindow : Adw.ApplicationWindow {
2727
private Adw.OverlaySplitView overlay_split_view;
2828
private Gtk.MenuButton settings_button;
2929
private Layouts.ItemSidebarView item_sidebar_view;
30+
private Gtk.Button fake_button;
3031

3132
public Services.ActionManager action_manager;
3233

@@ -60,6 +61,10 @@ public class MainWindow : Adw.ApplicationWindow {
6061

6162
var settings_popover = build_menu_app ();
6263

64+
fake_button = new Gtk.Button () {
65+
visible = false
66+
};
67+
6368
settings_button = new Gtk.MenuButton () {
6469
css_classes = { "flat" },
6570
popover = settings_popover,
@@ -79,6 +84,7 @@ public class MainWindow : Adw.ApplicationWindow {
7984
sidebar_header.add_css_class ("flat");
8085
sidebar_header.pack_end (settings_button);
8186
sidebar_header.pack_end (search_button);
87+
sidebar_header.pack_end (fake_button);
8288

8389
sidebar = new Layouts.Sidebar ();
8490

@@ -122,6 +128,7 @@ public class MainWindow : Adw.ApplicationWindow {
122128
Timeout.add (250, () => {
123129
init_backend ();
124130
overlay_split_view.show_sidebar = true;
131+
fake_button.grab_focus ();
125132
return GLib.Source.REMOVE;
126133
});
127134

@@ -265,7 +272,7 @@ public class MainWindow : Adw.ApplicationWindow {
265272
views_split_view.notify["show-sidebar"].connect (() => {
266273
if (!views_split_view.show_sidebar) {
267274
item_sidebar_view.disconnect_all ();
268-
search_button.grab_focus ();
275+
fake_button.grab_focus ();
269276
}
270277
});
271278
}

0 commit comments

Comments
 (0)