Move settings (‘Preferences’) into OS-level menu

This reduces our reliance on custom UI until we have more design resources.
This commit is contained in:
Daniel Gasienica
2018-02-27 16:10:27 -05:00
parent 027803f8f4
commit c5d5f5abb8
7 changed files with 60 additions and 0 deletions

View File

@@ -19,6 +19,10 @@
"message": "&Help",
"description": "The label that is used for the Help menu in the program main menu. The '&' indicates that the following letter will be used as the keyboard 'shortcut letter' for accessing the menu with the Alt-<letter> combination."
},
"mainMenuSettings": {
"message": "Preferences…",
"description": "The label that is used for the Preferences menu in the program main menu. This should be consistent with the standard naming for Preferences on the operating system."
},
"menuSetupWithImport": {
"message": "Set up with import",
"description": "When the application is not yet set up, menu option to start up the import sequence"

View File

@@ -18,11 +18,20 @@ exports.createTemplate = (options, messages) => {
setupWithImport,
showAbout,
showDebugLog,
showSettings,
} = options;
const template = [{
label: messages.mainMenuFile.message,
submenu: [
{
label: messages.mainMenuSettings.message,
accelerator: 'CommandOrControl+,',
click: showSettings,
},
{
type: 'separator',
},
{
role: 'quit',
},
@@ -218,6 +227,14 @@ function updateForMac(template, messages, options) {
{
type: 'separator',
},
{
label: messages.mainMenuSettings.message,
accelerator: 'CommandOrControl+,',
click: showSettings,
},
{
type: 'separator',
},
{
role: 'hide',
},

View File

@@ -170,6 +170,16 @@
Whisper.events.on('showDebugLog', function() {
appView.openDebugLog();
});
Whisper.events.on('showSettings', () => {
if (!appView || !appView.inboxView) {
console.log(
'background: Event: \'showSettings\':' +
' Expected `appView.inboxView` to exist.'
);
return;
}
appView.inboxView.showSettings();
});
Whisper.events.on('unauthorized', function() {
appView.inboxView.networkStatusView.update();
});

View File

@@ -324,6 +324,14 @@ function showDebugLog() {
}
}
function showSettings() {
if (!mainWindow) {
return;
}
mainWindow.webContents.send('show-settings');
}
function openReleaseNotes() {
shell.openExternal(`https://github.com/signalapp/Signal-Desktop/releases/tag/v${app.getVersion()}`);
}
@@ -449,6 +457,7 @@ function setupMenu(options) {
setupWithImport,
setupAsNewDevice,
setupAsStandalone,
showSettings,
});
const template = createTemplate(menuOptions, locale.messages);
const menu = Menu.buildFromTemplate(template);

View File

@@ -54,6 +54,10 @@
Whisper.events.trigger('setupAsStandalone');
});
ipc.on('show-settings', function() {
Whisper.events.trigger('showSettings');
});
window.addSetupMenuItems = function() {
ipc.send('add-setup-menu-items');
}

View File

@@ -8,6 +8,14 @@
{
"type": "separator"
},
{
"label": "Preferences…",
"accelerator": "CommandOrControl+,",
"click": null
},
{
"type": "separator"
},
{
"role": "hide"
},

View File

@@ -2,6 +2,14 @@
{
"label": "&File",
"submenu": [
{
"label": "Preferences…",
"accelerator": "CommandOrControl+,",
"click": null
},
{
"type": "separator"
},
{
"role": "quit"
}