diff options
-rw-r--r-- | Libraries/LibGUI/FilePicker.cpp | 3 | ||||
-rw-r--r-- | Libraries/LibGUI/MultiView.cpp | 22 | ||||
-rw-r--r-- | Libraries/LibGUI/MultiView.h | 12 |
3 files changed, 34 insertions, 3 deletions
diff --git a/Libraries/LibGUI/FilePicker.cpp b/Libraries/LibGUI/FilePicker.cpp index 3ae4187d63..5ee3a59751 100644 --- a/Libraries/LibGUI/FilePicker.cpp +++ b/Libraries/LibGUI/FilePicker.cpp @@ -156,9 +156,10 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& toolbar->add_action(m_view->view_as_icons_action()); toolbar->add_action(m_view->view_as_table_action()); - // FIXME: Enable this once GUI::ColumnsView doesn't crash when used here. +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_view->view_as_columns_action().set_enabled(false); toolbar->add_action(m_view->view_as_columns_action()); +#endif auto lower_container = vertical_container->add<Widget>(); lower_container->set_layout(make<VerticalBoxLayout>()); diff --git a/Libraries/LibGUI/MultiView.cpp b/Libraries/LibGUI/MultiView.cpp index 87334be9e4..27256da969 100644 --- a/Libraries/LibGUI/MultiView.cpp +++ b/Libraries/LibGUI/MultiView.cpp @@ -40,17 +40,22 @@ MultiView::MultiView() { set_active_widget(nullptr); m_item_view = add<ItemView>(); - m_columns_view = add<ColumnsView>(); m_table_view = add<TableView>(); +#ifdef MULTIVIEW_WITH_COLUMNSVIEW + m_columns_view = add<ColumnsView>(); +#endif + m_item_view->on_activation = [&](auto& index) { if (on_activation) on_activation(index); }; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_columns_view->on_activation = [&](auto& index) { if (on_activation) on_activation(index); }; +#endif m_table_view->on_activation = [&](auto& index) { if (on_activation) on_activation(index); @@ -64,10 +69,12 @@ MultiView::MultiView() if (on_selection_change) on_selection_change(); }; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_columns_view->on_selection_change = [this] { if (on_selection_change) on_selection_change(); }; +#endif m_table_view->on_context_menu_request = [this](auto& index, auto& event) { if (on_context_menu_request) @@ -77,10 +84,12 @@ MultiView::MultiView() if (on_context_menu_request) on_context_menu_request(index, event); }; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_columns_view->on_context_menu_request = [this](auto& index, auto& event) { if (on_context_menu_request) on_context_menu_request(index, event); }; +#endif m_table_view->on_drop = [this](auto& index, auto& event) { if (on_drop) @@ -90,11 +99,12 @@ MultiView::MultiView() if (on_drop) on_drop(index, event); }; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_columns_view->on_drop = [this](auto& index, auto& event) { if (on_drop) on_drop(index, event); }; - +#endif set_view_mode(ViewMode::Icon); build_actions(); @@ -114,10 +124,12 @@ void MultiView::set_view_mode(ViewMode mode) set_active_widget(m_table_view); return; } +#ifdef MULTIVIEW_WITH_COLUMNSVIEW if (mode == ViewMode::Columns) { set_active_widget(m_columns_view); return; } +#endif if (mode == ViewMode::Icon) { set_active_widget(m_item_view); return; @@ -141,7 +153,9 @@ void MultiView::set_model_column(int column) return; m_model_column = column; m_item_view->set_model_column(column); +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_columns_view->set_model_column(column); +#endif } void MultiView::set_column_hidden(int column_index, bool hidden) @@ -165,18 +179,22 @@ void MultiView::build_actions() }); m_view_as_icons_action->set_checkable(true); +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_view_as_columns_action = Action::create( "Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) { set_view_mode(ViewMode::Columns); m_view_as_columns_action->set_checked(true); }); m_view_as_columns_action->set_checkable(true); +#endif m_view_type_action_group = make<ActionGroup>(); m_view_type_action_group->set_exclusive(true); m_view_type_action_group->add_action(*m_view_as_table_action); m_view_type_action_group->add_action(*m_view_as_icons_action); +#ifdef MULTIVIEW_WITH_COLUMNSVIEW m_view_type_action_group->add_action(*m_view_as_columns_action); +#endif } } diff --git a/Libraries/LibGUI/MultiView.h b/Libraries/LibGUI/MultiView.h index 19e9a27749..98abc88b9b 100644 --- a/Libraries/LibGUI/MultiView.h +++ b/Libraries/LibGUI/MultiView.h @@ -32,6 +32,8 @@ #include <LibGUI/StackWidget.h> #include <LibGUI/TableView.h> +//#define MULTIVIEW_WITH_COLUMNSVIEW + namespace GUI { class MultiView final : public GUI::StackWidget { @@ -65,8 +67,10 @@ public: switch (m_view_mode) { case ViewMode::List: return *m_table_view; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW case ViewMode::Columns: return *m_columns_view; +#endif case ViewMode::Icon: return *m_item_view; default: @@ -82,7 +86,9 @@ public: { callback(*m_table_view); callback(*m_item_view); +#ifdef MULTIVIEW_WITH_COLUMNSVIEW callback(*m_columns_view); +#endif } Model* model() { return m_model; } @@ -92,7 +98,9 @@ public: Action& view_as_table_action() { return *m_view_as_table_action; } Action& view_as_icons_action() { return *m_view_as_icons_action; } +#ifdef MULTIVIEW_WITH_COLUMNSVIEW Action& view_as_columns_action() { return *m_view_as_columns_action; } +#endif private: MultiView(); @@ -106,11 +114,15 @@ private: RefPtr<TableView> m_table_view; RefPtr<ItemView> m_item_view; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW RefPtr<ColumnsView> m_columns_view; +#endif RefPtr<Action> m_view_as_table_action; RefPtr<Action> m_view_as_icons_action; +#ifdef MULTIVIEW_WITH_COLUMNSVIEW RefPtr<Action> m_view_as_columns_action; +#endif OwnPtr<ActionGroup> m_view_type_action_group; }; |