Make it easier to copy the Imgur link to the clipboard
AbandonedPublic

Authored by ngraham on May 30 2018, 7:12 PM.

Details

Reviewers
rkflx
Group Reviewers
Spectacle
Summary

Add a button to the KMessageWidget to make it really easy to copy the link to the clipboard.

CCBUG: 392722

We can still make this behavior automatic in the future if we want to, which would resolve 392722. Hopefully this should at least make it a bit easier.

Test Plan
  • The new button works, and the link is copied to the clipboard
  • If you click the "Copy to clipboard" button on the main window, the resulting KMessageWidget (correctly) doesn't display the "Copy link to clipboard" button
  • The "Copy to Clipboard" button still works and copies the image to the clipboard

Diff Detail

Repository
R166 Spectacle
Branch
easier-copy-imgur-link-to-clipboard (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
ngraham requested review of this revision.May 30 2018, 7:12 PM
ngraham created this revision.
ngraham edited the summary of this revision. (Show Details)May 30 2018, 7:15 PM
ngraham edited the test plan for this revision. (Show Details)

Idea is good, code needs some work.

mSharedImageURL needs resetting and
mMessageWidget->removeAction(mCopyUrlToClipboardAction); needs to happen in more places

From what I can tell reading this the same message widget is used for errors and when you normally copy an image.
So with this patch as-is if you take a screenshot and share it, then take another image and hit copy to clipboard it will copy the old link instead of the image and show an incorrect button.

rkflx requested changes to this revision.May 31 2018, 11:16 AM
rkflx added a subscriber: rkflx.

Thanks for the patch. I don't think having a dedicated button is strictly needed, as I'd rather turn on copying the link to the clipboard by default and communicate that through an inline message. Also, you can right-click on the link.

Still, for the quit-after-copy case this probably makes sense, so let's go with it (and I'm tired of arguing with you or David, TBH).

src/Gui/KSMainWindow.cpp
66

Isn't this equivalent to the default constructor of QString?

194

Please also set a more appropriate tooltip than the default one.

194

Title case.

195

Is this needed?

348–349

Moving code to the else block by indentation does not work in C++. Another reason why we should always use curly braces.

366

Hm, I don't really like how this is reusing sendToClipboard and then has to have two code paths based on mSharedImageURL.isEmpty().

This should be a dedicated slot. Let me refactor things a bit to make this easier for you and reduce code duplication. Won't take me long, promised (probably tonight).

371

QApplication::clipboard(), to make it consistent with the implementation in doCopyToClipboard().

372

You probably won't need this after my refactoring, but for the record, there is QString::clear().

This revision now requires changes to proceed.May 31 2018, 11:16 AM
rkflx added a comment.May 31 2018, 7:06 PM

Let me refactor things a bit to make this easier for you and reduce code duplication.

See D13247.

rkflx added a comment.EditedMay 31 2018, 7:26 PM

https://bugs.kde.org/show_bug.cgi?id=394181

change the string to just "Copy link", ommitting the "to clipboard" part.

That would be appreciated (and we could even think about doing the same for the button below, to keep consistency, e.g. Copy Screenshot?).

Edit: Hm, coming back I don't really like Copy Screenshot. Maybe just Copy? In every app's menu it's simply called "Copy", it should be clear by the resulting notification and lack of "..." that it copied directly to the clipboard anyway.

Also, Copy and Copy Link are different enough.


Alternatively, always copy the link automatically (i.e. no extra button, or rather only a delete button) and change the message accordingly.

ngraham updated this revision to Diff 35842.Jun 8 2018, 2:57 PM
ngraham marked 7 inline comments as done.

Rebase on master after @rkflx's improvements and address review comments

src/Gui/KSMainWindow.cpp
66

For some reason I needed to use QString() here to avoid a compilation error.

ngraham edited the test plan for this revision. (Show Details)Jun 8 2018, 3:01 PM

I'm thinking of abandoning this in favor of D13493: Auto-copy shared image link to clipboard. Any opinions?

ngraham abandoned this revision.Jun 19 2018, 2:47 AM

Formally abandoning this in favor of D13493, which really is a much better approach.