Skip to content

Commit 80b2154

Browse files
committed
Toolbar: Open local files
1 parent 28f6046 commit 80b2154

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Tab.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <QCoreApplication>
1313
#include <QStatusBar>
1414
#include <QLabel>
15+
#include <QFileDialog>
1516

1617
extern String s_serenity_resource_root;
1718
extern Browser::Settings* s_settings;
@@ -74,7 +75,6 @@ Tab::Tab(QMainWindow* window)
7475
m_break_cache_action = make<QAction>(QIcon(break_cache_icon_path), "Break cache");
7576
m_break_cache_action->setFont(button_text_font);
7677
m_open_action = make<QAction>(QIcon(open_icon_path), "Open");
77-
m_open_action->setEnabled(false);
7878
m_open_action->setFont(button_text_font);
7979
m_print_action = make<QAction>(QIcon(print_icon_path), "Print");
8080
m_print_action->setEnabled(false);
@@ -138,6 +138,7 @@ Tab::Tab(QMainWindow* window)
138138
QObject::connect(m_home_action, &QAction::triggered, this, &Tab::home);
139139
QObject::connect(m_reload_action, &QAction::triggered, this, &Tab::reload);
140140
QObject::connect(m_break_cache_action, &QAction::triggered, this, &Tab::break_cache);
141+
QObject::connect(m_open_action, &QAction::triggered, this, &Tab::open);
141142
QObject::connect(focus_location_edit_action, &QAction::triggered, m_location_edit, qOverload<>(&QWidget::setFocus));
142143
QObject::connect(focus_location_edit_action, &QAction::triggered, m_location_edit, &QLineEdit::selectAll);
143144
QObject::connect(focus_search_edit_action, &QAction::triggered, m_search_edit, qOverload<>(&QWidget::setFocus));
@@ -153,6 +154,14 @@ void Tab::navigate(QString url)
153154
view().load(url.toUtf8().data());
154155
}
155156

157+
void Tab::open()
158+
{
159+
160+
m_open_file = QFileDialog::getOpenFileName(this,
161+
tr("Open file in Coccinellidae"), "/", tr("All Files (*.*)"));
162+
navigate("file://"+m_open_file);
163+
}
164+
156165
void Tab::back()
157166
{
158167
if (!m_history.can_go_back())

Tab.h

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public slots:
3737
void home();
3838
void reload();
3939
void break_cache();
40+
void open();
4041

4142
signals:
4243
void title_changed(int id, QString);
@@ -52,6 +53,7 @@ public slots:
5253
QMainWindow* m_window { nullptr };
5354
Browser::History m_history;
5455
QString m_title;
56+
QString m_open_file;
5557

5658
OwnPtr<QAction> m_back_action;
5759
OwnPtr<QAction> m_forward_action;

0 commit comments

Comments
 (0)