mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
FileManager: Save the DirectoryView's visible columns
Since these are stored as numbers, and "1,2,3,5,6" is a bit meaningless to anyone who looks at this code, the default set of visible columns is provided as it was before, by them all being visible except a couple that are specifically hidden. The callback is wrapped in a debounce() so that if set_visible_columns () is called, we'll just save the value once instead of doing so for each column changed.
This commit is contained in:
parent
08edc872aa
commit
11af5119b6
1 changed files with 13 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
#include <AK/NumberFormat.h>
|
#include <AK/NumberFormat.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibConfig/Client.h>
|
#include <LibConfig/Client.h>
|
||||||
|
#include <LibCore/Debounce.h>
|
||||||
#include <LibCore/MimeData.h>
|
#include <LibCore/MimeData.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibFileSystem/FileSystem.h>
|
#include <LibFileSystem/FileSystem.h>
|
||||||
|
@ -294,8 +295,17 @@ void DirectoryView::setup_table_view()
|
||||||
m_table_view->set_model(m_sorting_model);
|
m_table_view->set_model(m_sorting_model);
|
||||||
m_table_view->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending);
|
m_table_view->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending);
|
||||||
|
|
||||||
m_table_view->set_column_visible(GUI::FileSystemModel::Column::Inode, false);
|
auto visible_columns = Config::read_string("FileManager"sv, "DirectoryView"sv, "TableColumns"sv, ""sv);
|
||||||
m_table_view->set_column_visible(GUI::FileSystemModel::Column::SymlinkTarget, false);
|
if (visible_columns.is_empty()) {
|
||||||
|
m_table_view->set_column_visible(GUI::FileSystemModel::Column::Inode, false);
|
||||||
|
m_table_view->set_column_visible(GUI::FileSystemModel::Column::SymlinkTarget, false);
|
||||||
|
} else {
|
||||||
|
m_table_view->set_visible_columns(visible_columns);
|
||||||
|
}
|
||||||
|
m_table_view->on_visible_columns_changed = Core::debounce(100, [this]() {
|
||||||
|
auto visible_columns = m_table_view->get_visible_columns().release_value_but_fixme_should_propagate_errors();
|
||||||
|
Config::write_string("FileManager"sv, "DirectoryView"sv, "TableColumns"sv, visible_columns);
|
||||||
|
});
|
||||||
|
|
||||||
m_table_view->on_activation = [&](auto& index) {
|
m_table_view->on_activation = [&](auto& index) {
|
||||||
handle_activation(index);
|
handle_activation(index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue