diff --git a/Userland/Applications/Maps/FavoritesEditDialog.h b/Userland/Applications/Maps/FavoritesEditDialog.h index 1df7d28514a..2fc85ae74aa 100644 --- a/Userland/Applications/Maps/FavoritesEditDialog.h +++ b/Userland/Applications/Maps/FavoritesEditDialog.h @@ -14,6 +14,9 @@ class FavoritesEditDialog final : public GUI::Widget { C_OBJECT(FavoritesEditDialog) public: static ErrorOr> try_create(); + +private: + FavoritesEditDialog() = default; }; } diff --git a/Userland/Applications/Maps/FavoritesModel.h b/Userland/Applications/Maps/FavoritesModel.h index 89ccd452860..fa7282b40f1 100644 --- a/Userland/Applications/Maps/FavoritesModel.h +++ b/Userland/Applications/Maps/FavoritesModel.h @@ -47,6 +47,8 @@ public: ErrorOr load_from_file(Core::File&); private: + FavoritesModel() = default; + Vector m_favorites; }; diff --git a/Userland/Applications/Maps/FavoritesPanel.cpp b/Userland/Applications/Maps/FavoritesPanel.cpp index b87ff5f063c..c568ec85412 100644 --- a/Userland/Applications/Maps/FavoritesPanel.cpp +++ b/Userland/Applications/Maps/FavoritesPanel.cpp @@ -116,8 +116,7 @@ ErrorOr FavoritesPanel::edit_favorite(GUI::ModelIndex const& index) void FavoritesPanel::favorites_changed() { // Update UI - m_empty_container->set_visible(m_model->row_count() == 0); - m_favorites_list->set_visible(m_model->row_count() > 0); + set_active_widget(m_model->row_count() == 0 ? m_empty_container : m_favorites_list); on_favorites_change(m_model->favorites()); // Save favorites diff --git a/Userland/Applications/Maps/FavoritesPanel.gml b/Userland/Applications/Maps/FavoritesPanel.gml index 4b1e8f449bb..8b1d4f69d4d 100644 --- a/Userland/Applications/Maps/FavoritesPanel.gml +++ b/Userland/Applications/Maps/FavoritesPanel.gml @@ -2,9 +2,7 @@ min_width: 100 preferred_width: 200 max_width: 350 - layout: @GUI::VerticalBoxLayout {} - // Empty and favorites are toggled in visibility @GUI::Frame { name: "empty_container" frame_style: "SunkenPanel" diff --git a/Userland/Applications/Maps/FavoritesPanel.h b/Userland/Applications/Maps/FavoritesPanel.h index 82ab82cce08..7be1eb43e44 100644 --- a/Userland/Applications/Maps/FavoritesPanel.h +++ b/Userland/Applications/Maps/FavoritesPanel.h @@ -8,10 +8,11 @@ #include "FavoritesModel.h" #include +#include namespace Maps { -class FavoritesPanel final : public GUI::Widget { +class FavoritesPanel final : public GUI::StackWidget { C_OBJECT(FavoritesPanel) public: @@ -26,10 +27,9 @@ public: Function const&)> on_favorites_change; Function on_selected_favorite_change; -protected: +private: FavoritesPanel() = default; -private: ErrorOr edit_favorite(GUI::ModelIndex const& index); void favorites_changed(); diff --git a/Userland/Applications/Maps/SearchPanel.cpp b/Userland/Applications/Maps/SearchPanel.cpp index 015c8e645a8..bd4251562ae 100644 --- a/Userland/Applications/Maps/SearchPanel.cpp +++ b/Userland/Applications/Maps/SearchPanel.cpp @@ -15,13 +15,11 @@ ErrorOr SearchPanel::initialize() m_search_textbox = *find_descendant_of_type_named("search_textbox"); m_search_button = *find_descendant_of_type_named("search_button"); + m_stack_widget = *find_descendant_of_type_named("stack_widget"); m_start_container = *find_descendant_of_type_named("start_container"); m_empty_container = *find_descendant_of_type_named("empty_container"); m_places_list = *find_descendant_of_type_named("places_list"); - m_empty_container->set_visible(false); - m_places_list->set_visible(false); - m_search_textbox->on_return_pressed = [this]() { search(MUST(String::from_byte_string(m_search_textbox->text()))); }; @@ -44,12 +42,9 @@ void SearchPanel::search(StringView query) { // Show start container when empty query if (query.is_empty()) { - m_start_container->set_visible(true); - m_empty_container->set_visible(false); - m_places_list->set_visible(false); + m_stack_widget->set_active_widget(m_start_container); return; } - m_start_container->set_visible(false); // Start HTTP GET request to load people.json HTTP::HeaderMap headers; @@ -78,8 +73,7 @@ void SearchPanel::search(StringView query) // Show empty label when no places are found auto json_places = result.release_value().as_array(); if (json_places.size() == 0) { - m_empty_container->set_visible(true); - m_places_list->set_visible(false); + m_stack_widget->set_active_widget(m_empty_container); return; } @@ -109,9 +103,8 @@ void SearchPanel::search(StringView query) on_places_change(m_places); // Update and show places list - m_empty_container->set_visible(false); m_places_list->set_model(*GUI::ItemListModel::create(m_places_names)); - m_places_list->set_visible(true); + m_stack_widget->set_active_widget(m_places_list); }); request->on_certificate_requested = []() -> Protocol::Request::CertificateAndKey { return {}; }; diff --git a/Userland/Applications/Maps/SearchPanel.gml b/Userland/Applications/Maps/SearchPanel.gml index 04744c59e0f..502627b5828 100644 --- a/Userland/Applications/Maps/SearchPanel.gml +++ b/Userland/Applications/Maps/SearchPanel.gml @@ -26,38 +26,41 @@ } } - // Start, empty and places are toggled in visibility - @GUI::Frame { - name: "start_container" - frame_style: "SunkenPanel" - layout: @GUI::VerticalBoxLayout { - margins: [4] + @GUI::StackWidget { + name: "stack_widget" + + @GUI::Frame { + name: "start_container" + frame_style: "SunkenPanel" + layout: @GUI::VerticalBoxLayout { + margins: [4] + } + + @GUI::Label { + text: "Enter a search query to search for places..." + text_alignment: "CenterLeft" + } } - @GUI::Label { - text: "Enter a search query to search for places..." - text_alignment: "CenterLeft" - } - } + @GUI::Frame { + name: "empty_container" + frame_style: "SunkenPanel" + layout: @GUI::VerticalBoxLayout { + margins: [4] + } - @GUI::Frame { - name: "empty_container" - frame_style: "SunkenPanel" - layout: @GUI::VerticalBoxLayout { - margins: [4] + @GUI::Label { + text: "Can't find any places with the search query" + text_alignment: "CenterLeft" + } } - @GUI::Label { - text: "Can't find any places with the search query" - text_alignment: "CenterLeft" + @GUI::ListView { + name: "places_list" + horizontal_padding: 6 + vertical_padding: 4 + should_hide_unnecessary_scrollbars: true + alternating_row_colors: false } } - - @GUI::ListView { - name: "places_list" - horizontal_padding: 6 - vertical_padding: 4 - should_hide_unnecessary_scrollbars: true - alternating_row_colors: false - } } diff --git a/Userland/Applications/Maps/SearchPanel.h b/Userland/Applications/Maps/SearchPanel.h index 9dd4e5049c0..8c98b731830 100644 --- a/Userland/Applications/Maps/SearchPanel.h +++ b/Userland/Applications/Maps/SearchPanel.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ private: RefPtr m_request; RefPtr m_search_textbox; RefPtr m_search_button; + RefPtr m_stack_widget; RefPtr m_start_container; RefPtr m_empty_container; RefPtr m_places_list; diff --git a/Userland/Applications/MapsSettings/MapsSettingsWidget.h b/Userland/Applications/MapsSettings/MapsSettingsWidget.h index f25dd3e7ac9..d65812a409c 100644 --- a/Userland/Applications/MapsSettings/MapsSettingsWidget.h +++ b/Userland/Applications/MapsSettings/MapsSettingsWidget.h @@ -23,7 +23,7 @@ public: private: MapsSettingsWidget() = default; - void set_tile_provider(StringView url); + void set_tile_provider(StringView tile_provider_url_format); RefPtr m_tile_provider_combobox; RefPtr m_custom_tile_provider_group;