mirror of https://github.com/laurent22/joplin.git
Desktop: Add button to About box to copy Joplin's information to the clipboard (#2711)
* add button to About box to copy Joplin's information to the clipboard 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). * remove hack to position button * add a new bridge function showMessageBox The function returns the index of the clicked button. * we don't need the first 3 lines (product name and copyright)pull/2789/head
parent
5ce79b1761
commit
3917e3469d
|
@ -23,7 +23,7 @@ const ResourceService = require('lib/services/ResourceService');
|
|||
const ClipperServer = require('lib/ClipperServer');
|
||||
const ExternalEditWatcher = require('lib/services/ExternalEditWatcher');
|
||||
const { bridge } = require('electron').remote.require('./bridge');
|
||||
const { shell, webFrame } = require('electron');
|
||||
const { shell, webFrame, clipboard } = require('electron');
|
||||
const Menu = bridge().Menu;
|
||||
const PluginManager = require('lib/services/PluginManager');
|
||||
const RevisionService = require('lib/services/RevisionService');
|
||||
|
@ -664,9 +664,17 @@ class Application extends BaseApplication {
|
|||
message.push(`\n${gitInfo}`);
|
||||
console.info(gitInfo);
|
||||
}
|
||||
bridge().showInfoMessageBox(message.join('\n'), {
|
||||
const text = message.join('\n');
|
||||
|
||||
const copyToClipboard = bridge().showMessageBox(text, {
|
||||
icon: `${bridge().electronApp().buildDir()}/icons/128x128.png`,
|
||||
buttons: [_('Copy'), _('OK')],
|
||||
cancelId: 1,
|
||||
defaultId: 1,
|
||||
});
|
||||
if (copyToClipboard === 0) {
|
||||
clipboard.writeText(message.splice(3).join('\n'));
|
||||
}
|
||||
}
|
||||
|
||||
const rootMenuFile = {
|
||||
|
|
|
@ -106,6 +106,19 @@ class Bridge {
|
|||
return result === 0;
|
||||
}
|
||||
|
||||
/* returns the index of the clicked button */
|
||||
showMessageBox(message, options = null) {
|
||||
if (options === null) options = {};
|
||||
|
||||
const result = this.showMessageBox_(this.window(), Object.assign({}, {
|
||||
type: 'question',
|
||||
message: message,
|
||||
buttons: [_('OK'), _('Cancel')],
|
||||
}, options));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
showInfoMessageBox(message, options = {}) {
|
||||
const result = this.showMessageBox_(this.window(), Object.assign({}, {
|
||||
type: 'info',
|
||||
|
|
Loading…
Reference in New Issue