Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Ladybird/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
close_current_tab_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Close));
menu->addAction(close_current_tab_action);

auto* open_file_action = new QAction("&Open File...", this);
open_file_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-folder-open.png").arg(s_serenity_resource_root.characters())));
open_file_action->setShortcut(QKeySequence(QKeySequence::StandardKey::Open));
menu->addAction(open_file_action);

menu->addSeparator();

auto* quit_action = new QAction("&Quit", this);
quit_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Quit));
menu->addAction(quit_action);
Expand All @@ -72,6 +79,8 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
edit_menu->addAction(m_select_all_action);
QObject::connect(m_select_all_action, &QAction::triggered, this, &BrowserWindow::select_all);

edit_menu->addSeparator();

auto* settings_action = new QAction("&Settings", this);
settings_action->setIcon(QIcon(QString("%1/res/icons/16x16/settings.png").arg(s_serenity_resource_root.characters())));
settings_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Preferences));
Expand Down Expand Up @@ -327,6 +336,7 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
QObject::connect(new_tab_action, &QAction::triggered, this, [this] {
new_tab(s_settings->new_tab_page(), Web::HTML::ActivateTab::Yes);
});
QObject::connect(open_file_action, &QAction::triggered, this, &BrowserWindow::open_file);
QObject::connect(settings_action, &QAction::triggered, this, [this] {
new SettingsDialog(this);
});
Expand Down Expand Up @@ -483,6 +493,11 @@ void BrowserWindow::close_tab(int index)
});
}

void BrowserWindow::open_file()
{
m_current_tab->open_file();
}

void BrowserWindow::close_current_tab()
{
auto count = m_tabs_container->count() - 1;
Expand Down
1 change: 1 addition & 0 deletions Ladybird/BrowserWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public slots:
void close_current_tab();
void open_next_tab();
void open_previous_tab();
void open_file();
void enable_auto_color_scheme();
void enable_light_color_scheme();
void enable_dark_color_scheme();
Expand Down
8 changes: 8 additions & 0 deletions Ladybird/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ void Tab::location_edit_return_pressed()
navigate(m_location_edit->text());
}

void Tab::open_file()
{
auto filename = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), tr("All Files (*.*)"));

if (!filename.isEmpty() && !filename.isNull())
navigate("file://" + filename);
}

int Tab::tab_index()
{
return m_window->tab_index(this);
Expand Down
4 changes: 4 additions & 0 deletions Ladybird/Tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "WebContentView.h"
#include <Browser/History.h>
#include <QBoxLayout>
#include <QFileDialog>
#include <QLabel>
#include <QLineEdit>
#include <QToolBar>
Expand Down Expand Up @@ -43,6 +44,7 @@ class Tab final : public QWidget {

void debug_request(DeprecatedString const& request, DeprecatedString const& argument);

void open_file();
void update_reset_zoom_button();

enum class InspectorTarget {
Expand Down Expand Up @@ -85,6 +87,7 @@ public slots:
Browser::History m_history;
QString m_title;
QLabel* m_hover_label { nullptr };
QString m_open_file;

OwnPtr<QMenu> m_page_context_menu;

Expand All @@ -101,6 +104,7 @@ public slots:
OwnPtr<QAction> m_video_context_menu_play_pause_action;
OwnPtr<QAction> m_video_context_menu_controls_action;
OwnPtr<QAction> m_video_context_menu_loop_action;
OwnPtr<QAction> m_open_file_action;
URL m_video_context_menu_url;

int tab_index();
Expand Down