Bug 52974 - [Qt] Add CopyImageUrlToClipboard action to QWebPage and QWKPage
Summary: [Qt] Add CopyImageUrlToClipboard action to QWebPage and QWKPage
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P5 Enhancement
Assignee: qi
URL:
Keywords: EasyFix, Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2011-01-23 02:26 PST by szyk
Modified: 2011-02-07 21:37 PST (History)
7 users (show)

See Also:


Attachments
patch (4.82 KB, patch)
2011-01-31 11:45 PST, qi
kling: review-
Details | Formatted Diff | Diff
patch2 (4.83 KB, patch)
2011-02-01 06:35 PST, qi
benjamin: review-
Details | Formatted Diff | Diff
patch3 (4.12 KB, patch)
2011-02-01 11:33 PST, qi
kling: review-
Details | Formatted Diff | Diff
patch4 (11.32 KB, patch)
2011-02-03 07:31 PST, qi
kling: review-
Details | Formatted Diff | Diff
patch5 (13.66 KB, patch)
2011-02-03 11:04 PST, qi
no flags Details | Formatted Diff | Diff
patch6 (13.66 KB, patch)
2011-02-04 06:34 PST, qi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description szyk 2011-01-23 02:26:02 PST
enum QWebPage::WebAction doesn't have value QWebPage::CopyImageUrl but obviously this is very frequent  action performed by users. By now I workaround this gap, but I think that such notorious action should by supported by default in standard way like other actions which can be performed on the web page.
Comment 1 Benjamin Poulain 2011-01-28 18:34:22 PST
Please follow http://trac.webkit.org/wiki/QtWebKitBugs when reporing bug here.

That is an easy patch to make if you want to add it yourself to WebKit ( https://trac.webkit.org/wiki/QtWebKitContrib )
Comment 2 qi 2011-01-31 11:45:20 PST
Created attachment 80667 [details]
patch

Introduce QWebPage::CopyImageUrlToClipboard into QWebPage:WebAction.
Comment 3 Andreas Kling 2011-01-31 13:07:51 PST
Comment on attachment 80667 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=80667&action=review

> Source/WebKit/qt/ChangeLog:8
> +        Add QWebPage::CopyImageUrlToClipborad into QWebPage::WebAction.

Typo, CopyImageUrlToClipboard.

> Source/WebKit/qt/Api/qwebpage.cpp:1684
> +    \value CopyImageUrlToClipboard Copy the highlighted image's url to the clipboard.

url -> URL

> Tools/ChangeLog:8
> +        Add CopyImageUrlToClipborad into QtTestbrowser.

Typo, CopyImageUrlToClipboard.

> Tools/QtTestBrowser/webview.cpp:247
> +        QAction* newTabAction = menu->addAction("Copy Image Address", webPage, SLOT(copyImageUrlToClipboard()));

The 'newTabAction' variable name doesn't make sense here.

> Tools/QtTestBrowser/webview.cpp:248
> +        menu->insertAction(menu->actions().at(4), newTabAction);

What's up with the at(4) here? How is the QMenu action list populated?
Comment 4 qi 2011-02-01 06:35:03 PST
Created attachment 80756 [details]
patch2

Based on comments to make some changes.

For the last issue "at(4)", because we already have another 3 menu items for image, they are "Open Image, Save Image, and Copy Image", and I want to put "Copy Image Address" after them, that' why. By the way, the other 3 actions come from WebKit common code, currently "Copy Image Address" is only for Qt, so we have to manually add into ContextMenu like "Open in Default Browser" did.
Comment 5 Benjamin Poulain 2011-02-01 06:39:37 PST
Food for thought: should that be added to the default actions of the context menu?
Comment 6 Chang Shu 2011-02-01 06:42:53 PST
> For the last issue "at(4)", because we already have another 3 menu items for image, they are "Open Image, Save Image, and Copy Image", and I want to put "Copy Image Address" after them, that' why. By the way, the other 3 actions come from WebKit common code, currently "Copy Image Address" is only for Qt, so we have to manually add into ContextMenu like "Open in Default Browser" did.

It's always good to avoid hardcoded numbers. Can't we do anything like append or get the length of current items, etc.?
Comment 7 qi 2011-02-01 07:06:37 PST
Let's make it more clear, currently, the ContextMenu like:

Open Image
Save Image
Copy Image
---------- (seperator)
Inspector


I want to insert the new menu item after "Copy Image", because I think it should be group with "Open...". So, you see it is difficult to use "append" or "length" to find the position. :(


Or, like Benjamin said put it into default actions. But I think then it will go into all the platform. Some platform, like Safari already have this, I think they suppose to add it manually like what I am doing now. If I put it into default, it maybe broke their behavior.
Comment 8 Chang Shu 2011-02-01 07:10:54 PST
good explanation. :)
Comment 9 Benjamin Poulain 2011-02-01 07:42:12 PST
(In reply to comment #7)
> Or, like Benjamin said put it into default actions. But I think then it will go into all the platform. Some platform, like Safari already have this, I think they suppose to add it manually like what I am doing now. If I put it into default, it maybe broke their behavior.

Someone already changed the behavior of the menu for this release. There is now "select all" for input fields.
If we change the menu, it is best to do it all at once and communicate about the changes (on the Qt blog for example).

I have CCed Andrea, the lead of the Rekonq project. Maybe he will have an opinion on the question.

The default menu is bad enough that hybrid and mobile redefine it anyway ;)
Comment 10 Benjamin Poulain 2011-02-01 07:58:57 PST
Comment on attachment 80756 [details]
patch2

You should not have to create the action yourself like you do in QTestBrowser.
QWebPage::action() should give you the action. You forgot to implement that part, that is why you need that code in QtTestBrowser.
Comment 11 Benjamin Poulain 2011-02-01 07:59:23 PST
(In reply to comment #10)
> (From update of attachment 80756 [details])
> You should not have to create the action yourself like you do in QTestBrowser.
> QWebPage::action() should give you the action. You forgot to implement that part, that is why you need that code in QtTestBrowser.

And an autotest would be nice... :)
Comment 12 qi 2011-02-01 08:51:15 PST
(In reply to comment #10)
> (From update of attachment 80756 [details])
> You should not have to create the action yourself like you do in QTestBrowser.
> QWebPage::action() should give you the action. You forgot to implement that part, that is why you need that code in QtTestBrowser.

I believe QWebPage::action() only for customize the display string. 

What items should be display by default is decided by WebCore/page/ContextMenuController.cpp/populate(), if we put this action into default (send it into common code), then we don't need manually add it into menu.
Comment 13 Benjamin Poulain 2011-02-01 09:06:13 PST
(In reply to comment #12)
> (In reply to comment #10)
> > (From update of attachment 80756 [details] [details])
> > You should not have to create the action yourself like you do in QTestBrowser.
> > QWebPage::action() should give you the action. You forgot to implement that part, that is why you need that code in QtTestBrowser.
> 
> I believe QWebPage::action() only for customize the display string. 

No it is not, it is the way standard actions are created. As a user, you should not have to do the connect from the action to actionTriggered.

Please check the code.....
Comment 14 qi 2011-02-01 11:33:23 PST
Created attachment 80794 [details]
patch3

Make some change based on comments, but I don't know how to create a auto test case (#11), do you have any example for it? Benjamin.
Comment 15 Andreas Kling 2011-02-01 16:30:28 PST
Comment on attachment 80794 [details]
patch3

View in context: https://bugs.webkit.org/attachment.cgi?id=80794&action=review

> Source/WebKit/qt/Api/qwebpage.cpp:2740
> +        case CopyImageUrlToClipboard:
> +            text =  tr("Copy Image Address");
> +            break;

This should be done through the platform strategy.
We'll need a contextMenuItemTagCopyImageURLToClipboard(), though it can be #if PLATFORM(QT) specific.
Comment 16 qi 2011-02-03 07:31:04 PST
Created attachment 81059 [details]
patch4

Put this action into standard action but Qt specific.
Comment 17 Early Warning System Bot 2011-02-03 07:50:44 PST
Attachment 81059 [details] did not build on qt:
Build output: http://queues.webkit.org/results/7693321
Comment 18 Andreas Kling 2011-02-03 09:05:49 PST
Comment on attachment 81059 [details]
patch4

Like EWS says, this breaks WebKit2. And speaking of WebKit2, the CopyImageUrlToClipboard action should also be added to the QWKPage WebActions.
Comment 19 qi 2011-02-03 11:04:07 PST
Created attachment 81090 [details]
patch5

Weird, I didn't get any build error in my workspace. Anyway, I changed webkit2 code and make a clean build, it works fine.
Comment 20 Early Warning System Bot 2011-02-03 12:51:41 PST
Attachment 81090 [details] did not build on qt:
Build output: http://queues.webkit.org/results/7691541
Comment 21 qi 2011-02-04 06:34:45 PST
Created attachment 81211 [details]
patch6

fix webkit2 build issue.
Comment 22 Andreas Kling 2011-02-07 08:35:30 PST
Comment on attachment 81211 [details]
patch6

r=me
Comment 23 WebKit Commit Bot 2011-02-07 21:37:13 PST
Comment on attachment 81211 [details]
patch6

Clearing flags on attachment: 81211

Committed r77892: <http://trac.webkit.org/changeset/77892>
Comment 24 WebKit Commit Bot 2011-02-07 21:37:19 PST
All reviewed patches have been landed.  Closing bug.