1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-23 18:53:36 +02:00

Added application menu

This commit is contained in:
Laurent Cozic 2017-11-11 12:00:37 +00:00
parent 61890d99ec
commit 6b3bda2941
5 changed files with 48 additions and 12 deletions

View File

@ -8,7 +8,6 @@ class ElectronAppWrapper {
constructor(electronApp) {
this.electronApp_ = electronApp;
//this.store_ = store;
this.win_ = null;
}

View File

@ -16,6 +16,10 @@ const { DatabaseDriverNode } = require('lib/database-driver-node.js');
const { ElectronAppWrapper } = require('./ElectronAppWrapper');
const { defaultState } = require('lib/reducer.js');
const { bridge } = require('electron').remote.require('./bridge');
const Menu = bridge().Menu;
const MenuItem = bridge().MenuItem;
const appDefaultState = Object.assign({}, defaultState, {
route: {
type: 'NAV_GO',
@ -89,9 +93,40 @@ class Application extends BaseApplication {
return super.generalMiddleware(store, next, action);
}
setupMenu() {
const template = [
{
label: 'File',
submenu: [{
label: _('Import Evernote notes'),
click () { }
}, {
label: _('Quit'),
accelerator: 'CommandOrControl+Q',
click: () => { bridge().electronApp().exit() }
}]
}, {
label: 'Help',
submenu: [{
label: _('Documentation'),
accelerator: 'F1',
click () { bridge().openExternal('http://joplin.cozic.net') }
}, {
label: _('About Joplin'),
click () { }
}]
},
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
}
async start(argv) {
argv = await super.start(argv);
this.setupMenu();
this.initRedux();
// Since the settings need to be loaded before the store is created, it will never
@ -123,10 +158,4 @@ function app() {
return application_;
}
function initApp(electronApp) {
if (application_) throw new Error('Application has already been initialized');
application_ = new Application(electronApp);
return application_;
}
module.exports = { app, initApp };
module.exports = { app };

View File

@ -6,6 +6,10 @@ class Bridge {
this.electronWrapper_ = electronWrapper;
}
electronApp() {
return this.electronWrapper_;
}
processArgv() {
return process.argv;
}
@ -54,6 +58,10 @@ class Bridge {
return require('electron').MenuItem;
}
openExternal(url) {
return require('electron').shell.openExternal(url)
}
}
let bridge_ = null;

View File

@ -14,7 +14,6 @@ const { Setting } = require('lib/models/setting.js');
const { Logger } = require('lib/logger.js');
const { FsDriverNode } = require('lib/fs-driver-node.js');
const { shimInit } = require('lib/shim-init-node.js');
const { bridge } = require('electron').remote.require('./bridge');
const fsDriver = new FsDriverNode();

View File

@ -16,14 +16,15 @@
"ReactNativeClient/locales/*",
"src/log.txt",
"*.min.js",
"ElectronClient/app/highlight/*.pack.js",
"ElectronClient/app/gui/note-viewer/css/font-awesome.min.css",
"ElectronClient/app/gui/note-viewer/highlight/*.pack.js",
"ElectronClient/app/css/font-awesome.min.css",
"_mydocs/mdtest/vendor/bin/html-to-markdown",
],
"folder_exclude_patterns":
[
"_mydocs/mdtest/Pages/Countries",
"_vieux",
"ElectronClient/app/fonts",
"CliClient/app/lib",
"CliClient/app/src",
"CliClient/build",
@ -44,7 +45,7 @@
"ReactNativeClient/android/local.properties",
"ReactNativeClient/ios",
"ReactNativeClient/node_modules",
"ElectronClient/app/highlight/styles",
"ElectronClient/app/gui/note-viewer/highlight/styles",
"tests/logs",
],
"path": "."