mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
QuickShow: Add Fullscreen, Zoom options to View menu
This commit is contained in:
parent
d79c81a179
commit
e0bf57d81f
3 changed files with 44 additions and 2 deletions
|
@ -109,6 +109,18 @@ void QSWidget::navigate(Directions direction)
|
|||
this->load_from_file(m_files_in_same_dir.at(index));
|
||||
}
|
||||
|
||||
void QSWidget::set_scale(int scale)
|
||||
{
|
||||
|
||||
if (scale < 10)
|
||||
scale = 10;
|
||||
if (scale > 1000)
|
||||
scale = 1000;
|
||||
|
||||
m_scale = scale;
|
||||
relayout();
|
||||
}
|
||||
|
||||
void QSWidget::relayout()
|
||||
{
|
||||
if (m_bitmap.is_null())
|
||||
|
@ -210,12 +222,13 @@ void QSWidget::load_from_file(const String& path)
|
|||
return;
|
||||
}
|
||||
|
||||
window()->resize(bitmap->size());
|
||||
|
||||
m_path = path;
|
||||
m_bitmap = bitmap;
|
||||
m_scale = 100;
|
||||
m_pan_origin = { 0, 0 };
|
||||
|
||||
resize_window();
|
||||
|
||||
if (on_scale_change)
|
||||
on_scale_change(m_scale);
|
||||
relayout();
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
|
||||
const Gfx::Bitmap* bitmap() const { return m_bitmap.ptr(); }
|
||||
const String& path() const { return m_path; }
|
||||
void set_scale(int);
|
||||
int scale() { return m_scale; }
|
||||
|
||||
void flip(Gfx::Orientation);
|
||||
void rotate(Gfx::RotationDirection);
|
||||
|
|
|
@ -143,6 +143,26 @@ int main(int argc, char** argv)
|
|||
widget.navigate(QSWidget::Directions::Last);
|
||||
});
|
||||
|
||||
auto full_sceen_action = GUI::CommonActions::make_fullscreen_action(
|
||||
[&](auto&) {
|
||||
window->set_fullscreen(!window->is_fullscreen());
|
||||
});
|
||||
|
||||
auto zoom_in_action = GUI::Action::create("Zoom In", { Mod_None, Key_Plus }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-in.png"),
|
||||
[&](auto&) {
|
||||
widget.set_scale(widget.scale() + 10);
|
||||
});
|
||||
|
||||
auto zoom_reset_action = GUI::Action::create("Zoom 100%", { Mod_None, Key_0 },
|
||||
[&](auto&) {
|
||||
widget.set_scale(100);
|
||||
});
|
||||
|
||||
auto zoom_out_action = GUI::Action::create("Zoom Out", { Mod_None, Key_Minus }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-out.png"),
|
||||
[&](auto&) {
|
||||
widget.set_scale(widget.scale() - 10);
|
||||
});
|
||||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
||||
auto& app_menu = menubar->add_menu("QuickShow");
|
||||
|
@ -169,6 +189,13 @@ int main(int argc, char** argv)
|
|||
navigate_menu.add_action(go_forward_action);
|
||||
navigate_menu.add_action(go_last_action);
|
||||
|
||||
auto& view_menu = menubar->add_menu("View");
|
||||
view_menu.add_action(full_sceen_action);
|
||||
view_menu.add_separator();
|
||||
view_menu.add_action(zoom_in_action);
|
||||
view_menu.add_action(zoom_reset_action);
|
||||
view_menu.add_action(zoom_out_action);
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
help_menu.add_action(GUI::Action::create("About", [&](auto&) {
|
||||
GUI::AboutDialog::show("QuickShow", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-image.png"), window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue