-
Notifications
You must be signed in to change notification settings - Fork 102
Context menu for links #46
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the commit message and title can be improved:
https://github.com/SerenityOS/serenity/blob/master/CONTRIBUTING.md#human-language-policy
I am not sure if this covered by Write in an authoritative and technical tone.
but I think that the commit messages should not contain self references "I did" etc.
2e33ec1
to
9d27920
Compare
I think something like this would be good for the back button so users can go back x number of pages in the history. A lot of pages are redirects and they stop me from going back a few pages. I'm looking at this myself but my Qt skills are very rusty. |
e817495
to
353c900
Compare
Rebased against main |
353c900
to
6474fc5
Compare
Rebased against main. Fixed the code standards. |
6474fc5
to
a2684b6
Compare
Rebased against main. |
a2684b6
to
5d67216
Compare
rebased against main. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message is missing a category, which will make it harder to pull into the serenity repo at a later date.
Utilities.cpp
Outdated
return QUrl(qstring_from_akstring(akurl.to_string())); | ||
} | ||
|
||
QPoint IntPoint_to_QPoint(Gfx::IntPoint const& position) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this Snakey_Camel_Case doesn't match our coding style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d8bf10f - ammended previous commit. Got it.
Tab.cpp
Outdated
auto copy_link_action = new QAction(tr("Copy Link")); | ||
auto open_link_in_tab_action = new QAction(tr("Open link in a new tab")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't been internationalizing anything in the serenity family of projects so far, and I don't see a reason to start now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separately, is there a way to tell Qt that we want a keyboard shortcut for these actions as well? I would expect us to have the actions for copy and paste stashed on the Tab or the BrowserWindow and just reference them here in this menu. I believe that's what the Serenity Browser implementation does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding i18n/l10n - I don't see a problem. When this project (which is not "strictly" tied to serenityOS) gets more stable - it will need. While I understand that this is not an issue now - it should not be a negative blocker.
Regarding shorthcuts, yes. Its a second argument something like QAction(tr(), "Ctrl+V")
(or other overloads). But you cannot use global actions, as these actions are "per link" or per "click". I added accelerators to the actions (&New tab
).
d8bf10f - ammended previous commit.
5d67216
to
d8bf10f
Compare
d8bf10f
to
1a28cc6
Compare
Rebased against main (upstream added full screen support) |
1a28cc6
to
12a650c
Compare
BrowserWindow.cpp
Outdated
@@ -282,9 +282,17 @@ void BrowserWindow::debug_request(String const& request, String const& argument) | |||
} | |||
|
|||
void BrowserWindow::new_tab() | |||
{ | |||
auto tab = make<Tab>(this, m_webdriver_fd_passing_socket); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? This will just go out of scope immediately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is the ways its coded currently on main
, I just copied into a new function. The the original context:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is new_tab
should now just be:
void BrowserWindow::new_tab()
{
new_tab_with_url({});
}
Because new_tab_with_url
is now the thing that calls make<Tab>(...)
and pushes the result onto m_tabs
to keep it alive. The invocation you've left here is now going to go out of scope immediately after returning and is a waste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
38f256d - got it
Tab.cpp
Outdated
if (res == copy_link_action) { | ||
QClipboard *clipboard = QGuiApplication::clipboard(); | ||
clipboard->setText(url.toString()); | ||
qDebug() << "Copied to clipboard text:" << url.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use dbgln
if we really need this log, otherwise let's not have it at all (or put it behind a dbgln_if
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed that debug. No problem.
Tab.cpp
Outdated
auto copy_link_action = new QAction(tr("&Copy Link")); | ||
auto open_link_in_tab_action = new QAction(tr("Open link in a &new tab")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use auto*
when the type is a pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done,
Tab.cpp
Outdated
qDebug() << "Copied to clipboard text:" << url.toString(); | ||
} else if (res == open_link_in_tab_action){ | ||
auto browser_window = static_cast<BrowserWindow*>(m_window); | ||
return browser_window->new_tab_with_url(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
is useless here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I am unaware how this even compiles.
Utilities.cpp
Outdated
@@ -45,3 +57,4 @@ void platform_init() | |||
}(); | |||
#endif | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this - please be sure to always run clang-format
on files, which would've removed this superfluous newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run another commit - with clang-format on all the code, This should be the second commit on this PR.
b4636bd
to
5da693c
Compare
5da693c
to
e68ed4f
Compare
This patch implements a context menu for links. In the future, we could even check for the modifiers and open links in new windows, or private windows - but not today.
This was too noisy IMHO - all project got cleaned up. Will also force-close this PR: LadybirdBrowser#76
e68ed4f
to
efe7983
Compare
rebased against main |
This patch implements a context menu for links. In the future, we could even check for the modifiers and open links in new windows, or private windows - but not today.