add parent directory button
This commit is contained in:
parent
a1e0e82da3
commit
96cd01bc77
5 changed files with 25 additions and 12 deletions
|
@ -14,11 +14,13 @@ void AppWidget::on_init() {
|
|||
|
||||
top_bar->on_action = [directory_view](TopBar::Action action) {
|
||||
if (action == TopBar::Action::Back) {
|
||||
directory_view->back();
|
||||
directory_view->go_back();
|
||||
} else if (action == TopBar::Action::Forward) {
|
||||
directory_view->forward();
|
||||
directory_view->go_forward();
|
||||
} else if (action == TopBar::Action::Home) {
|
||||
directory_view->home();
|
||||
directory_view->navigate_home();
|
||||
} else if (action == TopBar::Action::ParentDirectory) {
|
||||
directory_view->navigate_parent_directory();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -34,18 +34,22 @@ void DirectoryView::on_init() {
|
|||
|
||||
m_target = make_target();
|
||||
m_target->set_layout<Raven::DocumentLayout>(12.0);
|
||||
home();
|
||||
navigate_home();
|
||||
set_did_init(true);
|
||||
}
|
||||
|
||||
void DirectoryView::back() {
|
||||
void DirectoryView::go_back() {
|
||||
m_checkpoint_stack.undo();
|
||||
}
|
||||
|
||||
void DirectoryView::forward() {
|
||||
void DirectoryView::go_forward() {
|
||||
m_checkpoint_stack.redo();
|
||||
}
|
||||
|
||||
void DirectoryView::home() {
|
||||
void DirectoryView::navigate_home() {
|
||||
navigate(get_home_directory());
|
||||
}
|
||||
|
||||
void DirectoryView::navigate_parent_directory() {
|
||||
navigate(m_current_path.parent_path());
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ public:
|
|||
|
||||
void navigate(std::string path);
|
||||
void navigate_relative(std::string path);
|
||||
void back();
|
||||
void forward();
|
||||
void home();
|
||||
void go_back();
|
||||
void go_forward();
|
||||
void navigate_home();
|
||||
void navigate_parent_directory();
|
||||
protected:
|
||||
void set_current_path(std::filesystem::path path);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ void TopBar::on_init() {
|
|||
set_style(&Raven::accent_widget_style);
|
||||
|
||||
auto layout = set_layout<Raven::BoxLayout>(Raven::Direction::Horizontal);
|
||||
layout->slot_pixel(24, 3);
|
||||
layout->slot_pixel(24, 4);
|
||||
layout->set_margin(4);
|
||||
layout->set_spacing(8);
|
||||
|
||||
|
@ -17,6 +17,8 @@ void TopBar::on_init() {
|
|||
back_button->set_style(&Raven::default_button_style);
|
||||
auto forward_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/next.svg");
|
||||
forward_button->set_style(&Raven::default_button_style);
|
||||
auto parent_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/up.svg");
|
||||
parent_button->set_style(&Raven::default_button_style);
|
||||
auto home_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/go-home.svg");
|
||||
home_button->set_style(&Raven::default_button_style);
|
||||
|
||||
|
@ -29,6 +31,9 @@ void TopBar::on_init() {
|
|||
home_button->on_click = [this]() {
|
||||
on_action(Action::Home);
|
||||
};
|
||||
parent_button->on_click = [this]() {
|
||||
on_action(Action::ParentDirectory);
|
||||
};
|
||||
|
||||
set_did_init(true);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ public:
|
|||
enum class Action {
|
||||
Back = 0,
|
||||
Forward,
|
||||
Home
|
||||
Home,
|
||||
ParentDirectory
|
||||
};
|
||||
public:
|
||||
TopBar()
|
||||
|
|
Loading…
Reference in a new issue