summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHüseyin ASLITÜRK <asliturk@hotmail.com>2020-06-16 10:47:47 +0300
committerAndreas Kling <kling@serenityos.org>2020-06-16 14:42:18 +0200
commitbf3d98012ab9641c5935fda6aca0e176ac0e92c6 (patch)
treee4978fbfed107bbdf987a57973bda0e5f2ad59fc
parent016fc9c13327af4b0010cf65daf343235e48d8bc (diff)
downloadserenity-bf3d98012ab9641c5935fda6aca0e176ac0e92c6.zip
QuickShow: Switch to full screen mode on double click
More respect to user behavior on image viewers :)
-rw-r--r--Applications/QuickShow/QSWidget.cpp5
-rw-r--r--Applications/QuickShow/QSWidget.h2
-rw-r--r--Applications/QuickShow/main.cpp7
3 files changed, 12 insertions, 2 deletions
diff --git a/Applications/QuickShow/QSWidget.cpp b/Applications/QuickShow/QSWidget.cpp
index dfd60759f7..06cdb91ea5 100644
--- a/Applications/QuickShow/QSWidget.cpp
+++ b/Applications/QuickShow/QSWidget.cpp
@@ -160,6 +160,11 @@ void QSWidget::resize_event(GUI::ResizeEvent& event)
GUI::Widget::resize_event(event);
}
+void QSWidget::doubleclick_event(GUI::MouseEvent&)
+{
+ on_doubleclick();
+}
+
void QSWidget::paint_event(GUI::PaintEvent& event)
{
Frame::paint_event(event);
diff --git a/Applications/QuickShow/QSWidget.h b/Applications/QuickShow/QSWidget.h
index eade0a5ba1..432446c806 100644
--- a/Applications/QuickShow/QSWidget.h
+++ b/Applications/QuickShow/QSWidget.h
@@ -57,10 +57,12 @@ public:
void load_from_file(const String&);
Function<void(int)> on_scale_change;
+ Function<void()> on_doubleclick;
Function<void(const GUI::DropEvent&)> on_drop;
private:
QSWidget();
+ virtual void doubleclick_event(GUI::MouseEvent&) override;
virtual void paint_event(GUI::PaintEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp
index edf032b173..7430cbfa8b 100644
--- a/Applications/QuickShow/main.cpp
+++ b/Applications/QuickShow/main.cpp
@@ -103,6 +103,10 @@ int main(int argc, char** argv)
}
}
};
+ widget.on_doubleclick = [&] {
+ window->set_fullscreen(!window->is_fullscreen());
+ toolbar_container.set_visible(!window->is_fullscreen());
+ };
// Actions
auto open_action = GUI::CommonActions::make_open_action(
@@ -192,8 +196,7 @@ int main(int argc, char** argv)
auto full_sceen_action = GUI::CommonActions::make_fullscreen_action(
[&](auto&) {
- window->set_fullscreen(!window->is_fullscreen());
- toolbar_container.set_visible(!window->is_fullscreen());
+ widget.on_doubleclick();
});
auto zoom_in_action = GUI::Action::create("Zoom In", { Mod_None, Key_Plus }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-in.png"),