summaryrefslogtreecommitdiff
path: root/Applications/FileManager
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-30 02:22:38 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-30 02:22:38 +0100
commitf10e0d054612eef415ce96a0e2383910d39668c0 (patch)
treec7abc33c39c98287c55c6281d57d8bbaa405e850 /Applications/FileManager
parentbe42382a3a1c10585d272394557caed170ae0093 (diff)
downloadserenity-f10e0d054612eef415ce96a0e2383910d39668c0.zip
FileManager: Make the directory view follow the tree view selection.
Diffstat (limited to 'Applications/FileManager')
-rw-r--r--Applications/FileManager/main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 3d5feec079..708a6c9aec 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -54,7 +54,8 @@ int main(int argc, char** argv)
auto* splitter = new GWidget(widget);
splitter->set_layout(make<GBoxLayout>(Orientation::Horizontal));
auto* tree_view = new GTreeView(splitter);
- tree_view->set_model(GFileSystemModel::create("/", GFileSystemModel::Mode::DirectoriesOnly));
+ auto file_system_model = GFileSystemModel::create("/", GFileSystemModel::Mode::DirectoriesOnly);
+ tree_view->set_model(file_system_model.copy_ref());
tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
tree_view->set_preferred_size({ 200, 0 });
auto* directory_view = new DirectoryView(splitter);
@@ -70,6 +71,10 @@ int main(int argc, char** argv)
directory_view->open(editor.text());
};
+ file_system_model->on_selection_changed = [&] (auto& index) {
+ directory_view->open(file_system_model->path(index));
+ };
+
auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [directory_view] (const GAction&) {
directory_view->open_parent_directory();
});