ELECTRON-705 (Add custom title bar support for Window 7) (#490)

* ELECTRON-705 - Add custom title bar support for Window 7

* ELECTRON-705 - Optimize title bar menu selection logic and include detail section

* ELECTRON-705 - Change installer check box titles and des
This commit is contained in:
Kiran Niranjan 2018-09-03 16:25:46 +05:30 committed by Vishwas Shashidhar
parent 96707907c7
commit b4c559c3ee
9 changed files with 52 additions and 73 deletions

View File

@ -507,8 +507,8 @@
<ROW Dialog_="SettingsDlg" Control="Description" Type="Text" X="17" Y="21" Width="272" Height="14" Attributes="196611" Text="Select features for your users." Order="1900" TextLocId="Control.Text.FolderDlg#Description"/>
<ROW Dialog_="SettingsDlg" Control="PushButton_1" Type="PushButton" X="33" Y="243" Width="92" Height="17" Attributes="3" Text="Advance Settings" Order="2000"/>
<ROW Dialog_="SettingsDlg" Control="CustomTitleBarCheckBox" Type="CheckBox" X="33" Y="211" Width="98" Height="13" Attributes="3" Property="CUSTOM_TITLE_BAR_CB" Text="Enable" Order="2100"/>
<ROW Dialog_="SettingsDlg" Control="Text_9" Type="Text" X="33" Y="181" Width="117" Height="11" Attributes="65539" Property="TEXT_3_PROP_5_1" Text="Custom Title Bar" TextStyle="DlgFontBold8_DlgFontBold8" Order="2200"/>
<ROW Dialog_="SettingsDlg" Control="Text_10" Type="Text" X="33" Y="196" Width="147" Height="11" Attributes="65539" Property="TEXT_4_PROP_3_1" Text="Applies custom title bar style" Order="2300"/>
<ROW Dialog_="SettingsDlg" Control="Text_9" Type="Text" X="33" Y="181" Width="117" Height="11" Attributes="65539" Property="TEXT_3_PROP_5_1" Text="Enable Hamburger Menu" TextStyle="DlgFontBold8_DlgFontBold8" Order="2200"/>
<ROW Dialog_="SettingsDlg" Control="Text_10" Type="Text" X="33" Y="196" Width="147" Height="11" Attributes="65539" Property="TEXT_4_PROP_3_1" Text="Applies Hamburger style menu" Order="2300"/>
<ROW Dialog_="SettingsDlg" Control="DevToolsCheckBox" Type="CheckBox" X="185" Y="211" Width="98" Height="13" Attributes="3" Property="DEV_TOOLS_CB" Text="Enable" Order="2400"/>
<ROW Dialog_="SettingsDlg" Control="Text_11" Type="Text" X="185" Y="181" Width="117" Height="11" Attributes="65539" Property="TEXT_3_PROP_5_1_1" Text="Enable Dev Tools" TextStyle="DlgFontBold8_DlgFontBold8" Order="2500"/>
<ROW Dialog_="SettingsDlg" Control="Text_12" Type="Text" X="185" Y="196" Width="147" Height="11" Attributes="65539" Property="TEXT_4_PROP_3_1_1" Text="Enable dev tools for troubleshooting" Order="2600"/>

View File

@ -499,8 +499,8 @@
<ROW Dialog_="SettingsDlg" Control="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Attributes="196611" Text="Basic Settings" TextStyle="[DlgTitleFont]" Order="1900" TextLocId="Control.Text.FolderDlg#Title"/>
<ROW Dialog_="SettingsDlg" Control="Description" Type="Text" X="17" Y="21" Width="272" Height="14" Attributes="196611" Text="Select features for your users." Order="2000" TextLocId="Control.Text.FolderDlg#Description"/>
<ROW Dialog_="SettingsDlg" Control="CustomTitleBarCheckBox" Type="CheckBox" X="33" Y="209" Width="98" Height="13" Attributes="3" Property="CUSTOM_TITLE_BAR_CB" Text="Enable" Order="2100"/>
<ROW Dialog_="SettingsDlg" Control="Text_9" Type="Text" X="33" Y="179" Width="135" Height="11" Attributes="65539" Property="TEXT_3_PROP_5_1" Text="Custom Title Bar" TextStyle="DlgFontBold8_DlgFontBold8" Order="2200"/>
<ROW Dialog_="SettingsDlg" Control="Text_10" Type="Text" X="33" Y="194" Width="147" Height="11" Attributes="65539" Property="TEXT_4_PROP_3_1" Text="Applies custom title bar style" Order="2300"/>
<ROW Dialog_="SettingsDlg" Control="Text_9" Type="Text" X="33" Y="179" Width="135" Height="11" Attributes="65539" Property="TEXT_3_PROP_5_1" Text="Enable Hamburger Menu" TextStyle="DlgFontBold8_DlgFontBold8" Order="2200"/>
<ROW Dialog_="SettingsDlg" Control="Text_10" Type="Text" X="33" Y="194" Width="147" Height="11" Attributes="65539" Property="TEXT_4_PROP_3_1" Text="Applies Hamburger style menu" Order="2300"/>
<ROW Dialog_="SettingsDlg" Control="DevToolsCheckBox" Type="CheckBox" X="185" Y="209" Width="98" Height="13" Attributes="3" Property="DEV_TOOLS_CB" Text="Enable" Order="2400"/>
<ROW Dialog_="SettingsDlg" Control="Text_11" Type="Text" X="185" Y="179" Width="135" Height="11" Attributes="65539" Property="TEXT_3_PROP_5_1_1" Text="Enabled Dev Tools" TextStyle="DlgFontBold8_DlgFontBold8" Order="2500"/>
<ROW Dialog_="SettingsDlg" Control="Text_12" Type="Text" X="185" Y="194" Width="147" Height="11" Attributes="65539" Property="TEXT_4_PROP_3_1_1" Text="Enable dev tools for troubleshooting" Order="2600"/>

View File

@ -4,7 +4,7 @@ const fs = require('fs');
const electron = require('electron');
const { updateConfigField, getMultipleConfigField } = require('../config.js');
const { isMac, isWindowsOS, isWindows10 } = require('../utils/misc.js');
const { isMac, isWindowsOS } = require('../utils/misc.js');
const archiveHandler = require('../utils/archiveHandler');
const log = require('../log.js');
const logLevels = require('../enums/logLevels.js');
@ -376,54 +376,21 @@ function getTemplate(app) {
});
if (!isMac) {
/* eslint-disable no-param-reassign */
template[index].submenu.push({
label: titleBarStyle === titleBarStyles.NATIVE ?
i18n.getMessageFor('Enable Hamburger menu') :
i18n.getMessageFor('Disable Hamburger menu'),
click: function () {
const isNativeStyle = titleBarStyle === titleBarStyles.NATIVE;
if (isWindows10()) {
/* eslint-disable no-param-reassign */
template[index].submenu.push({
label: i18n.getMessageFor('Title Bar Style'),
submenu: [
{
label: i18n.getMessageFor('Native'),
type: 'checkbox',
checked: titleBarStyle === titleBarStyles.NATIVE,
enabled: titleBarStyle !== titleBarStyles.NATIVE,
click: function (item) {
const isNativeStyle = titleBarStyle === titleBarStyles.NATIVE;
item.menu.items[1].checked = isNativeStyle;
// Disable menu item accordingly
item.menu.items[0].enabled = isNativeStyle;
item.menu.items[1].enabled = !isNativeStyle;
titleBarStyle = titleBarStyles.NATIVE;
updateConfigField('isCustomTitleBar', false);
titleBarActions(app);
}
},
{
label: i18n.getMessageFor('Custom'),
type: 'checkbox',
checked: titleBarStyle === titleBarStyles.CUSTOM,
enabled: titleBarStyle !== titleBarStyles.CUSTOM,
click: function (item) {
const isCustomStyle = titleBarStyle === titleBarStyles.CUSTOM;
item.menu.items[0].checked = isCustomStyle;
// Disable menu item accordingly
item.menu.items[1].enabled = isCustomStyle;
item.menu.items[0].enabled = !isCustomStyle;
titleBarStyle = titleBarStyles.CUSTOM;
updateConfigField('isCustomTitleBar', true);
titleBarActions(app);
}
}
]
}, {
type: 'separator'
});
/* eslint-enable no-param-reassign */
}
titleBarStyle = isNativeStyle ? titleBarStyles.NATIVE : titleBarStyles.CUSTOM;
titleBarActions(app, isNativeStyle);
}
}, {
type: 'separator'
});
/* eslint-enable no-param-reassign */
template[index].submenu.push({
label: i18n.getMessageFor('Quit Symphony'),
@ -542,19 +509,26 @@ function getTitleBarStyle() {
* to relaunch application
*
* @param app
* @param isNativeStyle
*/
function titleBarActions(app) {
function titleBarActions(app, isNativeStyle) {
const options = {
type: 'question',
title: i18n.getMessageFor('Relaunch Application'),
message: i18n.getMessageFor('Updating Title bar style requires Symphony to relaunch'),
message: i18n.getMessageFor('Updating Title bar style requires Symphony to relaunch.'),
detail: i18n.getMessageFor('Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the Alt key.'),
buttons: [i18n.getMessageFor('Relaunch'), i18n.getMessageFor('Cancel')],
cancelId: 1
};
electron.dialog.showMessageBox(electron.BrowserWindow.getFocusedWindow(), options, function (index) {
if (index === 0) {
app.relaunch();
app.exit();
updateConfigField('isCustomTitleBar', !!isNativeStyle)
.then(() => {
app.relaunch();
app.exit();
}).catch((e) => {
log.send(logLevels.ERROR, `Unable to disable / enable hamburger menu due to error: ${e}`);
});
}
});
}

View File

@ -1,5 +1,4 @@
'use strict';
const os = require('os');
const isDevEnv = process.env.ELECTRON_DEV ?
process.env.ELECTRON_DEV.trim().toLowerCase() === 'true' : false;
@ -9,15 +8,9 @@ const isWindowsOS = (process.platform === 'win32');
const isNodeEnv = !!process.env.NODE_ENV;
function isWindows10() {
const [ major ] = os.release().split('.').map((part) => parseInt(part, 10));
return isWindowsOS && major >= 10;
}
module.exports = {
isDevEnv: isDevEnv,
isMac: isMac,
isWindowsOS: isWindowsOS,
isNodeEnv: isNodeEnv,
isWindows10: isWindows10
isNodeEnv: isNodeEnv
};

View File

@ -21,7 +21,7 @@ const notify = require('./notify/electron-notify.js');
const eventEmitter = require('./eventEmitter');
const throttle = require('./utils/throttle.js');
const { getConfigField, updateConfigField, readConfigFileSync, getMultipleConfigField } = require('./config.js');
const { isMac, isNodeEnv, isWindows10, isWindowsOS, isDevEnv } = require('./utils/misc');
const { isMac, isNodeEnv, isWindowsOS, isDevEnv } = require('./utils/misc');
const { isWhitelisted, parseDomain } = require('./utils/whitelistHandler');
const { initCrashReporterMain, initCrashReporterRenderer } = require('./crashReporter.js');
const i18n = require('./translation/i18n');
@ -136,7 +136,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
// condition whether to enable custom Windows 10 title bar
isCustomTitleBarEnabled = typeof isCustomTitleBar === 'boolean'
&& isCustomTitleBar
&& isWindows10();
&& isWindowsOS;
log.send(logLevels.INFO, `we are configuring a custom title bar for windows -> ${isCustomTitleBarEnabled}`);
ctWhitelist = config && config.ctWhitelist;
@ -248,7 +248,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
// Event needed to hide native menu bar on Windows 10 as we use custom menu bar
mainWindow.webContents.once('did-start-loading', () => {
if ((isCustomTitleBarEnabled || isWindows10()) && mainWindow && !mainWindow.isDestroyed()) {
if ((isCustomTitleBarEnabled || isWindowsOS) && mainWindow && !mainWindow.isDestroyed()) {
mainWindow.setMenuBarVisibility(false);
}
});
@ -1011,7 +1011,7 @@ function setLocale(browserWindow, opts) {
menu = electron.Menu.buildFromTemplate(getTemplate(app));
electron.Menu.setApplicationMenu(menu);
if (isWindows10()) {
if (isWindowsOS) {
browserWindow.setMenuBarVisibility(false);
// update locale for custom title bar
@ -1168,7 +1168,7 @@ function handleKeyPress(keyCode) {
break;
}
case KeyCodes.Alt:
if (isWindows10() && !isCustomTitleBarEnabled) {
if (isWindowsOS && !isCustomTitleBarEnabled) {
popupMenu();
}
break;

View File

@ -42,9 +42,11 @@
"Custom": "Custom",
"Cut": "Cut",
"Delete": "Delete",
"Disable Hamburger menu": "Disable Hamburger menu",
"Dev Tools disabled": "Dev Tools disabled",
"Dev Tools has been disabled. Please contact your system administrator": "Dev Tools has been disabled. Please contact your system administrator",
"Edit": "Edit",
"Enable Hamburger menu": "Enable Hamburger menu",
"Error loading configuration": "Error loading configuration",
"Error loading URL": "Error loading URL",
"Error loading window": "Error loading window",
@ -63,6 +65,7 @@
"No crashes available to share": "No crashes available to share",
"No logs are available to share": "No logs are available to share",
"Not Allowed": "Not Allowed",
"Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the Alt key.": "Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the \"Alt\" key.",
"NotificationSettings": {
"Bottom Left": "Bottom Left",
"Bottom Right": "Bottom Right",
@ -137,7 +140,7 @@
"Unable to generate crash reports due to ": "Unable to generate crash reports due to ",
"Unable to generate logs due to ": "Unable to generate logs due to ",
"Undo": "Undo",
"Updating Title bar style requires Symphony to relaunch": "Updating Title bar style requires Symphony to relaunch",
"Updating Title bar style requires Symphony to relaunch.": "Updating Title bar style requires Symphony to relaunch.",
"View": "View",
"Window": "Window",
"Your administrator has disabled": "Your administrator has disabled",

View File

@ -42,7 +42,9 @@
"Custom": "Custom",
"Cut": "Cut",
"Delete": "Delete",
"Disable Hamburger menu": "Disable Hamburger menu",
"Edit": "Edit",
"Enable Hamburger menu": "Enable Hamburger menu",
"Error loading configuration": "Error loading configuration",
"Error loading URL": "Error loading URL",
"Error loading window": "Error loading window",
@ -61,6 +63,7 @@
"No crashes available to share": "No crashes available to share",
"No logs are available to share": "No logs are available to share",
"Not Allowed": "Not Allowed",
"Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the Alt key.": "Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the \"Alt\" key.",
"NotificationSettings": {
"Bottom Left": "Bottom Left",
"Bottom Right": "Bottom Right",
@ -135,7 +138,7 @@
"Unable to generate crash reports due to ": "Unable to generate crash reports due to ",
"Unable to generate logs due to ": "Unable to generate logs due to ",
"Undo": "Undo",
"Updating Title bar style requires Symphony to relaunch": "Updating Title bar style requires Symphony to relaunch",
"Updating Title bar style requires Symphony to relaunch.": "Updating Title bar style requires Symphony to relaunch.",
"View": "View",
"Window": "Window",
"Your administrator has disabled": "Your administrator has disabled",

View File

@ -44,7 +44,9 @@
"Delete": "削除",
"Dev Tools disabled": "開発ツールを無効にする",
"Dev Tools has been disabled. Please contact your system administrator": "Dev Toolsが無効になっています。システム管理者に連絡してください",
"Disable Hamburger menu": "ハンバーガーメニューを無効にする",
"Edit": "編集",
"Enable Hamburger menu": "ハンバーガーメニューを有効にする",
"Error loading configuration": "構成の読み込みエラー",
"Error loading URL": "URLの読み込みエラー",
"Error loading window": "ウィンドウを読み込みエラー",
@ -63,6 +65,7 @@
"No crashes available to share": "共有できるクラッシュはありません",
"No logs are available to share": "共有できるログはありません",
"Not Allowed": "許可されていませ。",
"Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the Alt key.": "注ハンバーガーメニューが無効になっている場合、「Alt」キーを押してメインメニューをトリガーすることができます。",
"NotificationSettings": {
"Bottom Left": "左下",
"Bottom Right": "右下",
@ -137,7 +140,7 @@
"Unable to generate crash reports due to ": "クラッシュレポートを生成できません。理由: ",
"Unable to generate logs due to ": "ログを生成できません。理由:",
"Undo": "元に戻す",
"Updating Title bar style requires Symphony to relaunch": "タイトルバーのスタイルを更新するには、Symphonyが再起動する必要があります",
"Updating Title bar style requires Symphony to relaunch.": "タイトルバーのスタイルを更新するには、Symphonyが再起動する必要があります",
"View": "ビュー",
"Window": "ウインドウ",
"Your administrator has disabled": "管理者によて無効にされています",

View File

@ -42,7 +42,9 @@
"Custom": "カスタム",
"Cut": "切り取り",
"Delete": "削除",
"Disable Hamburger menu": "ハンバーガーメニューを無効にする",
"Edit": "編集",
"Enable Hamburger menu": "ハンバーガーメニューを有効にする",
"Error loading configuration": "構成の読み込みエラー",
"Error loading URL": "URLの読み込みエラー",
"Error loading window": "ウィンドウを読み込みエラー",
@ -61,6 +63,7 @@
"No crashes available to share": "共有できるクラッシュはありません",
"No logs are available to share": "共有できるログはありません",
"Not Allowed": "許可されていませ。",
"Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the Alt key.": "注ハンバーガーメニューが無効になっている場合、「Alt」キーを押してメインメニューをトリガーすることができます。",
"NotificationSettings": {
"Bottom Left": "左下",
"Bottom Right": "右下",
@ -135,7 +138,7 @@
"Unable to generate crash reports due to ": "クラッシュレポートを生成できません。理由: ",
"Unable to generate logs due to ": "ログを生成できません。理由:",
"Undo": "元に戻す",
"Updating Title bar style requires Symphony to relaunch": "タイトルバーのスタイルを更新するには、Symphonyが再起動する必要があります",
"Updating Title bar style requires Symphony to relaunch.": "タイトルバーのスタイルを更新するには、Symphonyが再起動する必要があります",
"View": "ビュー",
"Window": "ウインドウ",
"Your administrator has disabled": "管理者によて無効にされています",