Skip to content

Commit 0909925

Browse files
committed
Add shortcuts: Home (Alt+home), Open File (Ctrl+O), Page info (Ctrl+I), Cancel page load (Escape), Dump DOM Tree(Shift+Alt+1) - Dump Local Storage (Shift+Alt+7)
1 parent 73c097b commit 0909925

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

BrowserWindow.cpp

+26-5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
4141
close_current_tab_action->setShortcut(QKeySequence(QKeySequence::Close));
4242
menu->addAction(close_current_tab_action);
4343

44+
auto* open_file_action = new QAction("&Open File...");
45+
open_file_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-folder-open.png").arg(s_serenity_resource_root.characters())));
46+
open_file_action->setShortcut(QKeySequence(QKeySequence::Open)); // "Ctrl+O"
47+
menu->addAction(open_file_action);
48+
4449
menu->addSeparator();
4550

4651
auto* save_as_action = new QAction("&Save As");
@@ -143,6 +148,7 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
143148

144149
auto* document_info_action = new QAction("Document &Info");
145150
document_info_action->setIcon(QIcon(QString("%1/res/icons/16x16/app-text-editor.png").arg(s_serenity_resource_root.characters())));
151+
document_info_action->setShortcut(QKeySequence("Ctrl+I"));
146152
document_info_action->setEnabled(false);
147153
view_menu->addAction(document_info_action);
148154

@@ -182,11 +188,13 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
182188

183189
auto* go_home_action = new QAction("Home");
184190
go_home_action->setIcon(QIcon(QString("%1/res/icons/16x16/go-home.png").arg(s_serenity_resource_root.characters())));
191+
go_home_action->setShortcut(QKeySequence("Alt+Home")); // "Alt+Home"
185192
go_menu->addAction(go_home_action);
186193
QObject::connect(go_home_action, &QAction::triggered, this, &BrowserWindow::go_home);
187194

188195
auto* go_reload_action = new QAction("Reload");
189196
go_reload_action->setIcon(QIcon(QString("%1/res/icons/16x16/reload.png").arg(s_serenity_resource_root.characters())));
197+
go_reload_action->setShortcut(QKeySequence(QKeySequence::Refresh)); // "F5"
190198
go_menu->addAction(go_reload_action);
191199
QObject::connect(go_reload_action, &QAction::triggered, this, &BrowserWindow::go_reload);
192200

@@ -204,56 +212,63 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
204212

205213
auto* dump_dom_tree_action = new QAction("Dump DOM Tree");
206214
dump_dom_tree_action->setIcon(QIcon(QString("%1/res/icons/browser/dom-tree.png").arg(s_serenity_resource_root.characters())));
215+
dump_dom_tree_action->setShortcut(QKeySequence("Shift+Alt+1"));
207216
options_menu->addAction(dump_dom_tree_action);
208217
QObject::connect(dump_dom_tree_action, &QAction::triggered, this, [this] {
209218
debug_request("dump-dom-tree");
210219
});
211220

212221
auto* dump_layout_tree_action = new QAction("Dump Layout Tree");
213222
dump_layout_tree_action->setIcon(QIcon(QString("%1/res/icons/16x16/layout.png").arg(s_serenity_resource_root.characters())));
223+
dump_layout_tree_action->setShortcut(QKeySequence("Shift+Alt+2"));
214224
options_menu->addAction(dump_layout_tree_action);
215225
QObject::connect(dump_layout_tree_action, &QAction::triggered, this, [this] {
216226
debug_request("dump-layout-tree");
217227
});
218228

219229
auto* dump_stacking_context_tree_action = new QAction("Dump Stacking Context Tree");
220230
dump_stacking_context_tree_action->setIcon(QIcon(QString("%1/res/icons/16x16/layers.png").arg(s_serenity_resource_root.characters())));
231+
dump_stacking_context_tree_action->setShortcut(QKeySequence("Shift+Alt+3"));
221232
options_menu->addAction(dump_stacking_context_tree_action);
222233
QObject::connect(dump_stacking_context_tree_action, &QAction::triggered, this, [this] {
223234
debug_request("dump-stacking-context-tree");
224235
});
225236

226237
auto* dump_style_sheets_action = new QAction("Dump Style Sheets");
227238
dump_style_sheets_action->setIcon(QIcon(QString("%1/res/icons/16x16/filetype-css.png").arg(s_serenity_resource_root.characters())));
239+
dump_style_sheets_action->setShortcut(QKeySequence("Shift+Alt+4"));
228240
options_menu->addAction(dump_style_sheets_action);
229241
QObject::connect(dump_style_sheets_action, &QAction::triggered, this, [this] {
230242
debug_request("dump-style-sheets");
231243
});
232244

233245
auto* dump_history_action = new QAction("Dump History");
234246
dump_history_action->setIcon(QIcon(QString("%1/res/icons/16x16/history.png").arg(s_serenity_resource_root.characters())));
247+
dump_history_action->setShortcut(QKeySequence("Shift+Alt+5"));
235248
options_menu->addAction(dump_history_action);
236249
QObject::connect(dump_history_action, &QAction::triggered, this, [this] {
237250
debug_request("dump-history");
238251
});
239252

240253
auto* dump_cookies_action = new QAction("Dump Cookies");
241254
dump_cookies_action->setIcon(QIcon(QString("%1/res/icons/browser/cookie.png").arg(s_serenity_resource_root.characters())));
255+
dump_cookies_action->setShortcut(QKeySequence("Shift+Alt+6"));
242256
options_menu->addAction(dump_cookies_action);
243257
QObject::connect(dump_cookies_action, &QAction::triggered, this, [this] {
244258
debug_request("dump-cookies");
245259
});
246260

247261
auto* dump_local_storage_action = new QAction("Dump Local Storage");
248262
dump_local_storage_action->setIcon(QIcon(QString("%1/res/icons/browser/local-storage.png").arg(s_serenity_resource_root.characters())));
263+
dump_local_storage_action->setShortcut(QKeySequence("Shift+Alt+7"));
249264
options_menu->addAction(dump_local_storage_action);
250265
QObject::connect(dump_local_storage_action, &QAction::triggered, this, [this] {
251266
debug_request("dump-local-storage");
252267
});
253268

254269
options_menu->addSeparator();
255270

256-
auto* show_line_box_borders_action = new QAction("Show Line Box Borders");
271+
auto* show_line_box_borders_action = new QAction("Show Line &Box Borders");
257272
show_line_box_borders_action->setCheckable(true);
258273
options_menu->addAction(show_line_box_borders_action);
259274
QObject::connect(show_line_box_borders_action, &QAction::triggered, this, [this, show_line_box_borders_action] {
@@ -263,14 +278,14 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
263278

264279
options_menu->addSeparator();
265280

266-
auto* collect_garbage_action = new QAction("Collect Garbage!!");
281+
auto* collect_garbage_action = new QAction("Collect &Garbage");
267282
collect_garbage_action->setIcon(QIcon(QString("%1/res/icons/16x16/trash-can.png").arg(s_serenity_resource_root.characters())));
268283
options_menu->addAction(collect_garbage_action);
269284
QObject::connect(collect_garbage_action, &QAction::triggered, this, [this] {
270285
debug_request("collect-garbage");
271286
});
272287

273-
auto* clear_cache_action = new QAction("Clear Cache");
288+
auto* clear_cache_action = new QAction("Clear &Cache");
274289
clear_cache_action->setIcon(QIcon(QString("%1/res/icons/browser/clear-cache.png").arg(s_serenity_resource_root.characters())));
275290
options_menu->addAction(clear_cache_action);
276291
QObject::connect(clear_cache_action, &QAction::triggered, this, [this] {
@@ -279,7 +294,7 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
279294

280295
options_menu->addSeparator();
281296

282-
auto* enable_scripting_action = new QAction("Enable Scripting");
297+
auto* enable_scripting_action = new QAction("Enable &Scripting");
283298
enable_scripting_action->setCheckable(true);
284299
enable_scripting_action->setChecked(true);
285300
options_menu->addAction(enable_scripting_action);
@@ -288,7 +303,7 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
288303
debug_request("scripting", state ? "on" : "off");
289304
});
290305

291-
auto* enable_same_origin_policy_action = new QAction("Enable Same-Origin Policy");
306+
auto* enable_same_origin_policy_action = new QAction("Enable Same-&Origin Policy");
292307
enable_same_origin_policy_action->setCheckable(true);
293308
options_menu->addAction(enable_same_origin_policy_action);
294309
QObject::connect(enable_same_origin_policy_action, &QAction::triggered, this, [this, enable_same_origin_policy_action] {
@@ -316,6 +331,7 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
316331

317332
QObject::connect(new_tab_action, &QAction::triggered, this, &BrowserWindow::new_tab);
318333
QObject::connect(quit_action, &QAction::triggered, this, &QMainWindow::close);
334+
QObject::connect(open_file_action, &QAction::triggered, this, &BrowserWindow::open_file);
319335
QObject::connect(m_tabs_container, &QTabWidget::currentChanged, [this](int index) {
320336
setWindowTitle(QString("%1 - Coccinellidae").arg(m_tabs_container->tabText(index)));
321337
setWindowIcon(m_tabs_container->tabIcon(index));
@@ -331,6 +347,11 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
331347

332348
}
333349

350+
void BrowserWindow::open_file()
351+
{
352+
m_current_tab->open();
353+
}
354+
334355
void BrowserWindow::go_home()
335356
{
336357
m_current_tab->home();

BrowserWindow.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public slots:
4242
void go_back();
4343
void go_forward();
4444
void go_reload();
45+
void open_file();
4546

4647
private:
4748
void debug_request(String const& request, String const& argument = "");

Tab.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,14 @@ Tab::Tab(QMainWindow* window)
6060
auto find_icon_path = QString("../icons/find.png");
6161
auto stop_icon_path = QString("../icons/stop.png");
6262
m_back_action = make<QAction>(QIcon(back_icon_path), "Back");
63-
m_back_action->setShortcut(QKeySequence(QKeySequence::Back)); // "Alt+Left"
6463
m_back_action->setFont(button_text_font);
6564
m_back_action->setEnabled(false);
6665
m_forward_action = make<QAction>(QIcon(forward_icon_path), "Forward");
67-
m_forward_action->setShortcut(QKeySequence(QKeySequence::Forward)); // "Alt+Right"
6866
m_forward_action->setFont(button_text_font);
6967
m_forward_action->setEnabled(false);
7068
m_home_action = make<QAction>(QIcon(home_icon_path), "Home");
7169
m_home_action->setFont(button_text_font);
7270
m_reload_action = make<QAction>(QIcon(reload_icon_path), "Reload");
73-
m_reload_action->setShortcut(QKeySequence(QKeySequence::Refresh)); // "Ctrl+R"
7471
m_reload_action->setFont(button_text_font);
7572
m_break_cache_action = make<QAction>(QIcon(break_cache_icon_path), "Break cache");
7673
m_break_cache_action->setFont(button_text_font);
@@ -83,6 +80,7 @@ Tab::Tab(QMainWindow* window)
8380
m_find_action->setEnabled(false);
8481
m_find_action->setFont(button_text_font);
8582
m_stop_action = make<QAction>(QIcon(stop_icon_path), "Stop");
83+
m_stop_action->setShortcut(QKeySequence(QKeySequence::Cancel)); // "Escape"
8684
m_stop_action->setEnabled(false);
8785
m_stop_action->setFont(button_text_font);
8886

0 commit comments

Comments
 (0)