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) {
|
top_bar->on_action = [directory_view](TopBar::Action action) {
|
||||||
if (action == TopBar::Action::Back) {
|
if (action == TopBar::Action::Back) {
|
||||||
directory_view->back();
|
directory_view->go_back();
|
||||||
} else if (action == TopBar::Action::Forward) {
|
} else if (action == TopBar::Action::Forward) {
|
||||||
directory_view->forward();
|
directory_view->go_forward();
|
||||||
} else if (action == TopBar::Action::Home) {
|
} 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 = make_target();
|
||||||
m_target->set_layout<Raven::DocumentLayout>(12.0);
|
m_target->set_layout<Raven::DocumentLayout>(12.0);
|
||||||
home();
|
navigate_home();
|
||||||
set_did_init(true);
|
set_did_init(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoryView::back() {
|
void DirectoryView::go_back() {
|
||||||
m_checkpoint_stack.undo();
|
m_checkpoint_stack.undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoryView::forward() {
|
void DirectoryView::go_forward() {
|
||||||
m_checkpoint_stack.redo();
|
m_checkpoint_stack.redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoryView::home() {
|
void DirectoryView::navigate_home() {
|
||||||
navigate(get_home_directory());
|
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(std::string path);
|
||||||
void navigate_relative(std::string path);
|
void navigate_relative(std::string path);
|
||||||
void back();
|
void go_back();
|
||||||
void forward();
|
void go_forward();
|
||||||
void home();
|
void navigate_home();
|
||||||
|
void navigate_parent_directory();
|
||||||
protected:
|
protected:
|
||||||
void set_current_path(std::filesystem::path path);
|
void set_current_path(std::filesystem::path path);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ void TopBar::on_init() {
|
||||||
set_style(&Raven::accent_widget_style);
|
set_style(&Raven::accent_widget_style);
|
||||||
|
|
||||||
auto layout = set_layout<Raven::BoxLayout>(Raven::Direction::Horizontal);
|
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_margin(4);
|
||||||
layout->set_spacing(8);
|
layout->set_spacing(8);
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ void TopBar::on_init() {
|
||||||
back_button->set_style(&Raven::default_button_style);
|
back_button->set_style(&Raven::default_button_style);
|
||||||
auto forward_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/next.svg");
|
auto forward_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/next.svg");
|
||||||
forward_button->set_style(&Raven::default_button_style);
|
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");
|
auto home_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/go-home.svg");
|
||||||
home_button->set_style(&Raven::default_button_style);
|
home_button->set_style(&Raven::default_button_style);
|
||||||
|
|
||||||
|
@ -29,6 +31,9 @@ void TopBar::on_init() {
|
||||||
home_button->on_click = [this]() {
|
home_button->on_click = [this]() {
|
||||||
on_action(Action::Home);
|
on_action(Action::Home);
|
||||||
};
|
};
|
||||||
|
parent_button->on_click = [this]() {
|
||||||
|
on_action(Action::ParentDirectory);
|
||||||
|
};
|
||||||
|
|
||||||
set_did_init(true);
|
set_did_init(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@ public:
|
||||||
enum class Action {
|
enum class Action {
|
||||||
Back = 0,
|
Back = 0,
|
||||||
Forward,
|
Forward,
|
||||||
Home
|
Home,
|
||||||
|
ParentDirectory
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
TopBar()
|
TopBar()
|
||||||
|
|
Loading…
Reference in a new issue