Skip to content

Desktop: add button to About box to copy Joplin's information to the clipboard #2711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2020

Conversation

tessus
Copy link
Collaborator

@tessus tessus commented Mar 9, 2020

On certain OS it is not possible to copy the text in the About window.
This change allows to copy that info to the Clipboard.

Due to some shortfalls in Electron, it is not possible to set defaultId and cancelId to 0.
(Actually one can set them to 0, but the result is not what one would expect.)
Thus I had to move the default OK button to the left.

I also added a hack to position the OK button approximately in the middle of the dialog box (if the copyLabel is not longer than 14 characters).

image

On certain OS it is not possible to copy the text in the About window.
This change allows to copy that info to the Clipboard.

Due to some shortfalls in Electron, it is not possible to set `defaultId` and `cancelId` to 0.
(Actually one can set them to 0, but the result is not what one would expect.)
Thus I had to move the default `OK` button to the left.

I also added a hack to position the `OK` button approximately in the middle of the dialog box (if the copyLabel is not longer than 14 characters).
@tessus tessus added desktop All desktop platforms PR-tested labels Mar 9, 2020
@laurent22
Copy link
Owner

Sounds good, but how does it look if you don't add spacing hack? If it looks good enough, I'd prefer if we could avoid the hack.

@tessus
Copy link
Collaborator Author

tessus commented Mar 10, 2020

IMO it doesn't look very good. That's why I added the spacer, but that's just me. We can remove it.

image

image

Comment on lines 672 to 679
const copyToClipboard = bridge().showConfirmMessageBox(text, {
icon: `${bridge().electronApp().buildDir()}/icons/128x128.png`,
buttons: [spacer + copyLabel + spacer, _('OK')],
defaultId: 1,
});
if (copyToClipboard) {
clipboard.writeText(text);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than overriding the behaviour of the showConfirmMessageBox, could you create a new bridge function showMessageBox, which calls showMessageBox_ and that can be used for special cases like this one, and that would return the exact buttonId that was clicked on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do. I'll do this in the afternoon.

@laurent22
Copy link
Owner

I think it looks good enough without the hack. I'm worry that a future upgrade of Electron would break the hack, or that it works on macOS but not on Windows or Linux, so if you could remove it that would be great.

@tessus
Copy link
Collaborator Author

tessus commented Mar 10, 2020

Not sure why Electron would break the hack, since it has nothing to do with Electron. It just makes the Copy button larger. Anyway, I'll remove it.

tessus added 2 commits March 10, 2020 15:57
The function returns the index of the clicked button.
@tessus
Copy link
Collaborator Author

tessus commented Mar 10, 2020

Done.

@tessus
Copy link
Collaborator Author

tessus commented Mar 11, 2020

Ready to merge.

@tessus
Copy link
Collaborator Author

tessus commented Mar 12, 2020

Anything still missing?

@laurent22
Copy link
Owner

Looks good, thanks @tessus!

@laurent22 laurent22 merged commit 3917e34 into laurent22:master Mar 12, 2020
@tessus
Copy link
Collaborator Author

tessus commented Mar 12, 2020

Thanks, I try to get a few PRs merged, since I am only allowed to merge doc and translation PRs. They are piling up and at one point it becomes unmanageable.

@tessus tessus deleted the feature/about-copy branch March 12, 2020 23:25
@laurent22
Copy link
Owner

Well GSoC is making the project busy, but it doesn't matter, the pull requests will be reviewed eventually. It will take the time it will take.

@tessus
Copy link
Collaborator Author

tessus commented Mar 12, 2020

As long as you are not overwhelmed with all these PRs I agree.
Let me know, if I can help out somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants