mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
Ladybird: Add "Open File..." to menu
This commit is contained in:
parent
e8af912e30
commit
5f39a3f911
4 changed files with 21 additions and 0 deletions
|
@ -65,6 +65,11 @@ 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);
|
||||
|
@ -349,6 +354,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);
|
||||
});
|
||||
|
@ -504,6 +510,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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QClipboard>
|
||||
#include <QCoreApplication>
|
||||
#include <QCursor>
|
||||
#include <QFileDialog>
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QGuiApplication>
|
||||
|
@ -523,6 +524,13 @@ void Tab::location_edit_return_pressed()
|
|||
navigate(m_location_edit->text());
|
||||
}
|
||||
|
||||
void Tab::open_file()
|
||||
{
|
||||
auto filename = QFileDialog::getOpenFileName(this, "Open file", QDir::homePath(), "All Files (*.*)");
|
||||
if (!filename.isNull())
|
||||
navigate("file://" + filename);
|
||||
}
|
||||
|
||||
int Tab::tab_index()
|
||||
{
|
||||
return m_window->tab_index(this);
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
void debug_request(DeprecatedString const& request, DeprecatedString const& argument);
|
||||
|
||||
void open_file();
|
||||
void update_reset_zoom_button();
|
||||
|
||||
enum class InspectorTarget {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue