mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
ImageViewer: Make arrow key shortcuts work
The user can now navigate to the previous and next image using the left and right arrow keys respectively. These shortcuts were previously not working.
This commit is contained in:
parent
2a32f8ad42
commit
b983dc8807
|
@ -7,6 +7,7 @@ serenity_component(
|
|||
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
MainWidget.cpp
|
||||
ViewWidget.cpp
|
||||
)
|
||||
|
||||
|
|
23
Userland/Applications/ImageViewer/MainWidget.cpp
Normal file
23
Userland/Applications/ImageViewer/MainWidget.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "MainWidget.h"
|
||||
|
||||
namespace ImageViewer {
|
||||
|
||||
MainWidget::MainWidget()
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_spacing(2);
|
||||
}
|
||||
|
||||
void MainWidget::keydown_event(GUI::KeyEvent& event)
|
||||
{
|
||||
event.ignore();
|
||||
}
|
||||
|
||||
}
|
25
Userland/Applications/ImageViewer/MainWidget.h
Normal file
25
Userland/Applications/ImageViewer/MainWidget.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
namespace ImageViewer {
|
||||
|
||||
class MainWidget final : public GUI::Widget {
|
||||
C_OBJECT(MainWidget)
|
||||
|
||||
public:
|
||||
virtual ~MainWidget() override = default;
|
||||
|
||||
private:
|
||||
MainWidget();
|
||||
virtual void keydown_event(GUI::KeyEvent& event) final;
|
||||
};
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "MainWidget.h"
|
||||
#include "ViewWidget.h"
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -56,10 +57,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
window->set_title("Image Viewer");
|
||||
|
||||
auto root_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
root_widget->set_fill_with_background_color(true);
|
||||
root_widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
root_widget->layout()->set_spacing(2);
|
||||
auto root_widget = TRY(window->set_main_widget<MainWidget>());
|
||||
|
||||
auto toolbar_container = TRY(root_widget->try_add<GUI::ToolbarContainer>());
|
||||
auto main_toolbar = TRY(toolbar_container->try_add<GUI::Toolbar>());
|
||||
|
|
Loading…
Reference in a new issue