diff --git a/installer/win/Symphony-x64.aip b/installer/win/Symphony-x64.aip index ea740ada..45eac0ac 100644 --- a/installer/win/Symphony-x64.aip +++ b/installer/win/Symphony-x64.aip @@ -43,16 +43,27 @@ + + + + + + + + + + + @@ -60,6 +71,7 @@ + @@ -102,28 +114,36 @@ + + + + - + + + + + @@ -170,7 +190,10 @@ + + + @@ -183,6 +206,7 @@ + @@ -197,6 +221,11 @@ + + + + + @@ -213,6 +242,8 @@ + + @@ -228,10 +259,12 @@ + + - + diff --git a/js/aboutApp/about-app.html b/js/aboutApp/about-app.html new file mode 100644 index 00000000..1ed09910 --- /dev/null +++ b/js/aboutApp/about-app.html @@ -0,0 +1,52 @@ + + + + + About Symphony + + + +
+ + Symphony + + +
+ + diff --git a/js/aboutApp/index.js b/js/aboutApp/index.js new file mode 100644 index 00000000..5a000adc --- /dev/null +++ b/js/aboutApp/index.js @@ -0,0 +1,83 @@ +'use strict'; + +const electron = require('electron'); +const BrowserWindow = electron.BrowserWindow; +const path = require('path'); +const fs = require('fs'); +const log = require('../log.js'); +const logLevels = require('../enums/logLevels.js'); + +let aboutWindow; + +let windowConfig = { + width: 350, + height: 260, + show: false, + modal: true, + autoHideMenuBar: true, + titleBarStyle: true, + resizable: false, + webPreferences: { + preload: path.join(__dirname, 'renderer.js'), + sandbox: true, + nodeIntegration: false + } +}; + +/** + * method to get the HTML template path + * @returns {string} + */ +function getTemplatePath() { + let templatePath = path.join(__dirname, 'about-app.html'); + try { + fs.statSync(templatePath).isFile(); + } catch (err) { + log.send(logLevels.ERROR, 'about-window: Could not find template ("' + templatePath + '").'); + } + return 'file://' + templatePath; +} + +/** + * Opens the about application window for a specific window + * @param {String} windowName - name of the window upon + * which this window should show + */ +function openAboutWindow(windowName) { + let allWindows = BrowserWindow.getAllWindows(); + allWindows = allWindows.find((window) => { return window.winName === windowName }); + + // if we couldn't find any window matching the window name + // it will render as a new window + if (allWindows) { + windowConfig.parent = allWindows; + } + + aboutWindow = new BrowserWindow(windowConfig); + aboutWindow.setVisibleOnAllWorkspaces(true); + aboutWindow.loadURL(getTemplatePath()); + + aboutWindow.once('ready-to-show', () => { + aboutWindow.show(); + }); + + aboutWindow.on('close', () => { + destroyWindow(); + }); + + aboutWindow.on('closed', () => { + destroyWindow(); + }); +} + +/** + * Destroys a window + */ +function destroyWindow() { + aboutWindow = null; +} + + +module.exports = { + openAboutWindow: openAboutWindow +}; \ No newline at end of file diff --git a/js/aboutApp/renderer.js b/js/aboutApp/renderer.js new file mode 100644 index 00000000..808c4337 --- /dev/null +++ b/js/aboutApp/renderer.js @@ -0,0 +1,21 @@ +'use strict'; +const { remote } = require('electron'); + +renderDom(); + +/** + * Method that renders application data + */ +function renderDom() { + document.addEventListener('DOMContentLoaded', function () { + const applicationName = remote.app.getName() || 'Symphony'; + const version = remote.app.getVersion(); + let appName = document.getElementById('app-name'); + let versionText = document.getElementById('version'); + let copyright = document.getElementById('copyright'); + + appName.innerHTML = applicationName; + versionText.innerHTML = version ? `Version ${version} (${version})` : null; + copyright.innerHTML = `Copyright © ${new Date().getFullYear()} ${applicationName}` + }); +} diff --git a/js/aboutApp/symphony-logo.png b/js/aboutApp/symphony-logo.png new file mode 100644 index 00000000..749cf2fc Binary files /dev/null and b/js/aboutApp/symphony-logo.png differ diff --git a/js/downloadManager/index.js b/js/downloadManager/index.js index bf7ac47e..dba2151c 100644 --- a/js/downloadManager/index.js +++ b/js/downloadManager/index.js @@ -56,9 +56,10 @@ function showInFinder(id) { function createDOM(arg) { if (arg && arg._id) { + let fileDisplayName = getFileDisplayName(arg.fileName); + let downloadItemKey = arg._id; local.downloadItems.push(arg); - let downloadItemKey = arg._id; let ul = document.getElementById('download-main'); if (ul) { @@ -108,7 +109,8 @@ function createDOM(arg) { let h2FileName = document.createElement('h2'); h2FileName.classList.add('text-cutoff'); - h2FileName.innerHTML = arg.fileName; + h2FileName.innerHTML = fileDisplayName; + h2FileName.title = fileDisplayName; fileNameDiv.appendChild(h2FileName); let fileProgressTitle = document.createElement('span'); @@ -194,4 +196,33 @@ function initiate() { }); } } +} + +/** + * Return a file display name for the download item + */ +function getFileDisplayName(fileName) { + let fileList = local.downloadItems; + let fileNameCount = 0; + let fileDisplayName = fileName; + + /* Check if a file with the same name exists + * (akin to the user downloading a file with the same name again) + * in the download bar + */ + for (let i = 0; i < fileList.length; i++) { + if (fileName === fileList[i].fileName) { + fileNameCount++; + } + } + + /* If it exists, add a count to the name like how Chrome does */ + if (fileNameCount) { + let extLastIndex = fileDisplayName.lastIndexOf('.'); + let fileCount = ' (' + fileNameCount + ')'; + + fileDisplayName = fileDisplayName.slice(0, extLastIndex) + fileCount + fileDisplayName.slice(extLastIndex); + } + + return fileDisplayName; } \ No newline at end of file diff --git a/js/menus/menuTemplate.js b/js/menus/menuTemplate.js index dd0bb460..ab822603 100644 --- a/js/menus/menuTemplate.js +++ b/js/menus/menuTemplate.js @@ -7,6 +7,7 @@ const isMac = require('../utils/misc.js').isMac; const log = require('../log.js'); const logLevels = require('../enums/logLevels.js'); const eventEmitter = require('../eventEmitter'); +const aboutApp = require('../aboutApp'); let minimizeOnClose = false; let launchOnStartup = false; @@ -246,6 +247,15 @@ function getTemplate(app) { app.quit(); } }); + + // This adds About Symphony under help menu for windows + template[3].submenu.push({ + label: 'About Symphony', + click(focusedWindow) { + let windowName = focusedWindow ? focusedWindow.name : ''; + aboutApp.openAboutWindow(windowName); + } + }); } return template; diff --git a/js/preload/preloadMain.js b/js/preload/preloadMain.js index 79bab139..0ed79a1d 100644 --- a/js/preload/preloadMain.js +++ b/js/preload/preloadMain.js @@ -26,26 +26,26 @@ require('../downloadManager'); // so loading the spellchecker in try catch so that we don't // block other method from loading document.addEventListener('DOMContentLoaded', () => { - //loadSpellChecker(); + loadSpellChecker(); }); /** * Loads up the spell checker module */ -// function loadSpellChecker() { -// try { -// /* eslint-disable global-require */ -// const SpellCheckerHelper = require('../spellChecker').SpellCheckHelper; -// /* eslint-enable global-require */ -// // Method to initialize spell checker -// const spellChecker = new SpellCheckerHelper(); -// spellChecker.initializeSpellChecker(); -// } catch (err) { -// /* eslint-disable no-console */ -// console.error('unable to load the spell checker module, hence, skipping the spell check feature ' + err); -// /* eslint-enable no-console */ -// } -// } +function loadSpellChecker() { + try { + /* eslint-disable global-require */ + const SpellCheckerHelper = require('../spellChecker').SpellCheckHelper; + /* eslint-enable global-require */ + // Method to initialize spell checker + const spellChecker = new SpellCheckerHelper(); + spellChecker.initializeSpellChecker(); + } catch (err) { + /* eslint-disable no-console */ + console.error('unable to load the spell checker module, hence, skipping the spell check feature ' + err); + /* eslint-enable no-console */ + } +} // hold ref so doesn't get GC'ed const local = { diff --git a/js/windowMgr.js b/js/windowMgr.js index 49b00c5b..5aae2f51 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -395,6 +395,11 @@ function doCreateMainWindow(initialUrl, initialBounds) { addWindowKey(newWinKey, browserWin); + // Method that sends bound changes as soon + // as a new window is created + // issue https://perzoinc.atlassian.net/browse/ELECTRON-172 + sendChildWinBoundsChange(browserWin); + // throttle changes so we don't flood client. let throttledBoundsChange = throttle(1000, sendChildWinBoundsChange.bind(null, browserWin)); diff --git a/package.json b/package.json index 23209abb..1ccb4ba3 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,8 @@ "async.mapseries": "^0.5.2", "auto-launch": "^5.0.1", "electron-dl": "^1.9.0", - "electron-log": "^2.2.7", + "electron-log": "^2.2.7", + "electron-spellchecker": "^1.1.2", "electron-squirrel-startup": "^1.0.0", "filesize": "^3.5.10", "keymirror": "0.1.1",