diff --git a/config/Symphony.config b/config/Symphony.config index 92c88c90..fe86d00c 100644 --- a/config/Symphony.config +++ b/config/Symphony.config @@ -3,6 +3,7 @@ "minimizeOnClose" : true, "launchOnStartup" : true, "alwaysOnTop" : false, + "bringToFront": false, "whitelistUrl": "*", "notificationSettings": { "position": "upper-right", diff --git a/installer/mac/SymphonySettingsPlugin.bundle/Contents/MacOS/SymphonySettingsPlugin b/installer/mac/SymphonySettingsPlugin.bundle/Contents/MacOS/SymphonySettingsPlugin index bc7b725a..e4276387 100755 Binary files a/installer/mac/SymphonySettingsPlugin.bundle/Contents/MacOS/SymphonySettingsPlugin and b/installer/mac/SymphonySettingsPlugin.bundle/Contents/MacOS/SymphonySettingsPlugin differ diff --git a/installer/mac/SymphonySettingsPlugin.bundle/Contents/Resources/Base.lproj/MyInstallerPane.nib b/installer/mac/SymphonySettingsPlugin.bundle/Contents/Resources/Base.lproj/MyInstallerPane.nib index e0e1caf6..be3518cd 100644 Binary files a/installer/mac/SymphonySettingsPlugin.bundle/Contents/Resources/Base.lproj/MyInstallerPane.nib and b/installer/mac/SymphonySettingsPlugin.bundle/Contents/Resources/Base.lproj/MyInstallerPane.nib differ diff --git a/installer/mac/SymphonySettingsPlugin.bundle/Contents/_CodeSignature/CodeResources b/installer/mac/SymphonySettingsPlugin.bundle/Contents/_CodeSignature/CodeResources index 97c3e45b..0154c96c 100644 --- a/installer/mac/SymphonySettingsPlugin.bundle/Contents/_CodeSignature/CodeResources +++ b/installer/mac/SymphonySettingsPlugin.bundle/Contents/_CodeSignature/CodeResources @@ -6,7 +6,7 @@ Resources/Base.lproj/MyInstallerPane.nib - GZWN47BPj6b6mD6MnSVH/Qn0m3s= + REWscTugC7Nqck170ufKwa7niM8= Resources/InstallerSections.plist @@ -37,11 +37,11 @@ hash - GZWN47BPj6b6mD6MnSVH/Qn0m3s= + REWscTugC7Nqck170ufKwa7niM8= hash2 - cJ/kr1HEozYL0YeZriWDtnOL1NEd22vHzH5WGp1T3hk= + 7tVq2ZiKqlKpvUpE6okEaYi4n4W8rSdip7Oxp23CKC8= Resources/InstallerSections.plist diff --git a/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/Base.lproj/MyInstallerPane.xib b/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/Base.lproj/MyInstallerPane.xib index e40c4504..f3f226a0 100644 --- a/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/Base.lproj/MyInstallerPane.xib +++ b/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/Base.lproj/MyInstallerPane.xib @@ -1,13 +1,14 @@ - + - + + @@ -18,6 +19,8 @@ + + @@ -39,7 +42,7 @@ - + @@ -48,7 +51,7 @@ - + @@ -57,21 +60,13 @@ - @@ -82,7 +77,7 @@ - + @@ -91,7 +86,7 @@ + diff --git a/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.h b/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.h index 16de5579..acd6c83a 100644 --- a/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.h +++ b/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.h @@ -14,5 +14,7 @@ @property (weak) IBOutlet NSTextField *podUrlTextBox; @property (weak) IBOutlet NSButton *alwaysOnTopCheckBox; @property (weak) IBOutlet NSTextField *podUrlAlertTextBox; +@property (weak) IBOutlet NSButton *bringToFrontCheckBox; +@property (weak) IBOutlet NSTextField *bringToFrontTextBox; @end diff --git a/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.m b/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.m index 1ad998be..b62c94fd 100644 --- a/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.m +++ b/installer/mac/SymphonySettingsPlugin/SymphonySettingsPlugin/MyInstallerPane.m @@ -63,16 +63,22 @@ minimizeOnClose = @"false"; } - // By default, set alwaysOnTop to false - NSString *alwaysOnTop = @"false\n"; + // By default, set alwaysOnTop and bring to front to false + NSString *alwaysOnTop = @"false"; + NSString *bringToFront = @"false\n"; // If the checkbox is changed, set the always on top value accordingly if ([_alwaysOnTopCheckBox state] == 1) { - alwaysOnTop = @"true\n"; + alwaysOnTop = @"true"; + } + + // If the checkbox is changed, set the bring to front value accordingly + if ([_bringToFrontCheckBox state] == 1) { + bringToFront = @"true\n"; } // Create an array with the selected options - NSArray *symSettings = [[NSArray alloc] initWithObjects:podUrl, minimizeOnClose, autoLaunchOnStart, alwaysOnTop, nil]; + NSArray *symSettings = [[NSArray alloc] initWithObjects:podUrl, minimizeOnClose, autoLaunchOnStart, alwaysOnTop, bringToFront, nil]; // Create a string from the array with new-line as the separator NSString *symSettingsString = [symSettings componentsJoinedByString:@"\n"]; diff --git a/installer/mac/postinstall.sh b/installer/mac/postinstall.sh index 3fab11a3..0faee3a3 100755 --- a/installer/mac/postinstall.sh +++ b/installer/mac/postinstall.sh @@ -11,6 +11,7 @@ pod_url=$(sed -n '1p' ${tempFilePath}); minimize_on_close=$(sed -n '2p' '/tmp/sym_settings.txt'); launch_on_startup=$(sed -n '3p' '/tmp/sym_settings.txt'); always_on_top=$(sed -n '4p' '/tmp/sym_settings.txt'); +bring_to_front=$(sed -n '5p' '/tmp/sym_settings.txt'); if [ "$pod_url" == "" ]; then pod_url="https://corporate.symphony.com" @@ -28,11 +29,16 @@ if [ "$always_on_top" == "" ]; then always_on_top=false; fi +if [ "$bring_to_front" == "" ]; then + bring_to_front=false; +fi + ## Replace the default settings with the user selected settings ## sed -i "" -E "s#\"url\" ?: ?\".*\"#\"url\"\: \"$pod_url\"#g" ${newPath} sed -i "" -E "s#\"minimizeOnClose\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"minimizeOnClose\":\ $minimize_on_close#g" ${newPath} sed -i "" -E "s#\"alwaysOnTop\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"alwaysOnTop\":\ $always_on_top#g" ${newPath} sed -i "" -E "s#\"launchOnStartup\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"launchOnStartup\":\ $launch_on_startup#g" ${newPath} +sed -i "" -E "s#\"bringToFront\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"bringToFront\":\ $bring_to_front#g" ${newPath} ## Remove the temp settings file created ## rm -f ${tempFilePath} diff --git a/installer/win/Symphony-x64.aip b/installer/win/Symphony-x64.aip index 7663bb00..0de7ebcf 100644 --- a/installer/win/Symphony-x64.aip +++ b/installer/win/Symphony-x64.aip @@ -20,6 +20,7 @@ + @@ -346,6 +347,7 @@ + @@ -388,6 +390,7 @@ + @@ -461,7 +464,9 @@ - + + + @@ -471,7 +476,7 @@ - + @@ -484,6 +489,8 @@ + + @@ -553,11 +560,11 @@ - + - + @@ -645,6 +652,7 @@ + diff --git a/js/bringToFront.js b/js/bringToFront.js new file mode 100644 index 00000000..6d6274c5 --- /dev/null +++ b/js/bringToFront.js @@ -0,0 +1,30 @@ +'use strict'; + +const windowMgr = require('./windowMgr.js'); +const { getConfigField } = require('./config.js'); +const log = require('./log.js'); +const logLevels = require('./enums/logLevels.js'); + +/** + * Method that checks if user has enabled the bring to front feature + * if so then activates the main window + * @param windowName - Name of the window to activate + */ +function bringToFront(windowName) { + + getConfigField('bringToFront') + .then((bringToFrontSetting) => { + if (typeof bringToFrontSetting === 'boolean' && bringToFrontSetting) { + log.send(logLevels.INFO, 'Window has been activated for: bringToFront'); + windowMgr.activate(windowName || 'main'); + } + }) + .catch((error) => { + log.send(logLevels.ERROR, 'Could not read bringToFront field from config error= ' + error); + }); +} + + +module.exports = { + bringToFront: bringToFront +}; \ No newline at end of file diff --git a/js/mainApiMgr.js b/js/mainApiMgr.js index 4473165f..bd7c85d1 100644 --- a/js/mainApiMgr.js +++ b/js/mainApiMgr.js @@ -13,6 +13,7 @@ const activityDetection = require('./activityDetection'); const badgeCount = require('./badgeCount.js'); const protocolHandler = require('./protocolHandler'); const configureNotification = require('./notify/settings/configure-notification-position'); +const { bringToFront } = require('./bringToFront.js'); const eventEmitter = require('./eventEmitter'); const { isMac } = require('./utils/misc'); @@ -102,6 +103,11 @@ electron.ipcMain.on(apiName, (event, arg) => { break; case apiCmds.activate: if (typeof arg.windowName === 'string') { + // validates the user bring to front config and activates the wrapper + if (typeof arg.reason === 'string' && arg.reason === 'bringToFront') { + bringToFront(arg.windowName); + break; + } windowMgr.activate(arg.windowName); } break; diff --git a/js/menus/menuTemplate.js b/js/menus/menuTemplate.js index fda638df..5afcec22 100644 --- a/js/menus/menuTemplate.js +++ b/js/menus/menuTemplate.js @@ -9,9 +9,18 @@ const logLevels = require('../enums/logLevels.js'); const eventEmitter = require('../eventEmitter'); const aboutApp = require('../aboutApp'); +const configFields = [ + 'minimizeOnClose', + 'launchOnStartup', + 'alwaysOnTop', + 'notificationSettings', + 'bringToFront' +]; + let minimizeOnClose = false; let launchOnStartup = false; let isAlwaysOnTop = false; +let bringToFront = false; let symphonyAutoLauncher; @@ -254,6 +263,17 @@ function getTemplate(app) { } }); + // Window menu -> bringToFront + template[index].submenu.push({ + label: 'Bring to Front on Notifications', + type: 'checkbox', + checked: bringToFront, + click: function(item) { + bringToFront = item.checked; + updateConfigField('bringToFront', bringToFront); + } + }); + if (!isMac) { template[index].submenu.push({ label: 'Quit Symphony', @@ -284,7 +304,7 @@ function setCheckboxValues() { /** * Method that reads multiple config fields */ - getMultipleConfigField(['minimizeOnClose', 'launchOnStartup', 'alwaysOnTop', 'notificationSettings']) + getMultipleConfigField(configFields) .then(function (configData) { for (let key in configData) { if (configData.hasOwnProperty(key)) { // eslint-disable-line no-prototype-builtins @@ -302,6 +322,9 @@ function setCheckboxValues() { case 'notificationSettings': eventEmitter.emit('notificationSettings', configData[key]); break; + case 'bringToFront': + bringToFront = configData[key]; + break; default: break; } diff --git a/js/notify/notifyImpl.js b/js/notify/notifyImpl.js index 285f447b..363123aa 100644 --- a/js/notify/notifyImpl.js +++ b/js/notify/notifyImpl.js @@ -109,6 +109,7 @@ class Notify { this.destroy(); } } + } /** diff --git a/js/preload/preloadMain.js b/js/preload/preloadMain.js index 0c4a42a7..846133d8 100644 --- a/js/preload/preloadMain.js +++ b/js/preload/preloadMain.js @@ -151,11 +151,13 @@ function createAPI() { /** * Brings window forward and gives focus. * @param {String} windowName Name of window. Note: main window name is 'main' + * @param {String} reason, The reason for which the window is to be activated */ - activate: function(windowName) { + activate: function(windowName, reason) { local.ipcRenderer.send(apiName, { cmd: apiCmds.activate, - windowName: windowName + windowName: windowName, + reason: reason }); }, diff --git a/js/windowMgr.js b/js/windowMgr.js index 1bfb4431..3dc0a287 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -591,6 +591,7 @@ function activate(windowName) { if (window && !window.isDestroyed() && window.winName === windowName) { if (window.isMinimized()) { window.restore(); + window.focus(); } else { window.show(); }