From 63ba0bc93636de557ced29c19b2b61eeeab57bf8 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 15 Sep 2024 19:20:41 +0200 Subject: Refresh "Add account" UI --- main/src/windows/conversation_details.vala | 103 ++--------------------------- 1 file changed, 4 insertions(+), 99 deletions(-) (limited to 'main/src/windows') diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala index 7ffa01f1..c2484db8 100644 --- a/main/src/windows/conversation_details.vala +++ b/main/src/windows/conversation_details.vala @@ -153,112 +153,17 @@ namespace Dino.Ui.ConversationDetails { } if (model.about_rows.get_n_items() > 0) { - about_box.append(rows_to_preference_group(model.about_rows, _("About"))); + about_box.append(Util.rows_to_preference_group(model.about_rows, _("About"))); } if (model.encryption_rows.get_n_items() > 0) { - about_box.append(rows_to_preference_group(model.encryption_rows, _("Encryption"))); + about_box.append(Util.rows_to_preference_group(model.encryption_rows, _("Encryption"))); } if (model.settings_rows.get_n_items() > 0) { - about_box.append(rows_to_preference_group(model.settings_rows, _("Settings"))); + about_box.append(Util.rows_to_preference_group(model.settings_rows, _("Settings"))); } if (model.room_configuration_rows != null && model.room_configuration_rows.get_n_items() > 0) { - about_box.append(rows_to_preference_group(model.room_configuration_rows, _("Room Configuration"))); + about_box.append(Util.rows_to_preference_group(model.room_configuration_rows, _("Room Configuration"))); } } - - private Adw.PreferencesGroup rows_to_preference_group(GLib.ListStore row_view_models, string title) { - var preference_group = new Adw.PreferencesGroup() { title=title }; - - for (int preference_group_i = 0; preference_group_i < row_view_models.get_n_items(); preference_group_i++) { - var preferences_row = (ViewModel.PreferencesRow.Any) row_view_models.get_item(preference_group_i); - - Widget? w = null; - - var entry_view_model = preferences_row as ViewModel.PreferencesRow.Entry; - if (entry_view_model != null) { -#if Adw_1_2 - Adw.EntryRow view = new Adw.EntryRow() { title = entry_view_model.title, show_apply_button=true }; - entry_view_model.bind_property("text", view, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL, (_, from, ref to) => { - var str = (string) from; - to = str ?? ""; - return true; - }); - view.apply.connect(() => { - entry_view_model.changed(); - }); -#else - var view = new Adw.ActionRow() { title = entry_view_model.title }; - var entry = new Entry() { text=entry_view_model.text, valign=Align.CENTER }; - entry_view_model.bind_property("text", entry, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); - entry.changed.connect(() => { - entry_view_model.changed(); - }); - view.activatable_widget = entry; - view.add_suffix(entry); -#endif - w = view; - } - - var row_text = preferences_row as ViewModel.PreferencesRow.Text; - if (row_text != null) { - w = new Adw.ActionRow() { - title = row_text.title, - subtitle = row_text.text, -#if Adw_1_3 - subtitle_selectable = true -#endif - }; - w.add_css_class("property"); - - Util.force_css(w, "row.property > box.header > box.title > .title { font-weight: 400; font-size: 9pt; opacity: 0.55; }"); - Util.force_css(w, "row.property > box.header > box.title > .subtitle { font-size: inherit; opacity: 1; }"); - } - - var toggle_view_model = preferences_row as ViewModel.PreferencesRow.Toggle; - if (toggle_view_model != null) { - var view = new Adw.ActionRow() { title = toggle_view_model.title, subtitle = toggle_view_model.subtitle }; - var toggle = new Switch() { valign = Align.CENTER }; - view.activatable_widget = toggle; - view.add_suffix(toggle); - toggle_view_model.bind_property("state", toggle, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); - w = view; - } - - var combobox_view_model = preferences_row as ViewModel.PreferencesRow.ComboBox; - if (combobox_view_model != null) { - var string_list = new StringList(null); - foreach (string text in combobox_view_model.items) { - string_list.append(text); - } -#if Adw_1_4 - var view = new Adw.ComboRow() { title = combobox_view_model.title }; - view.model = string_list; - combobox_view_model.bind_property("active-item", view, "selected", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); -#else - var view = new Adw.ActionRow() { title = combobox_view_model.title }; - var drop_down = new DropDown(string_list, null) { valign = Align.CENTER }; - combobox_view_model.bind_property("active-item", drop_down, "selected", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); - view.activatable_widget = drop_down; - view.add_suffix(drop_down); -#endif - w = view; - } - - var widget_view_model = preferences_row as ViewModel.PreferencesRow.WidgetDeprecated; - if (widget_view_model != null) { - var view = new Adw.ActionRow() { title = widget_view_model.title }; - view.add_suffix(widget_view_model.widget); - w = view; - } - - if (w == null) { - continue; - } - - preference_group.add(w); - } - - return preference_group; - } } } -- cgit v1.2.3-70-g09d2