diff --git a/app/renderer/css/preference.css b/app/renderer/css/preference.css index 6babd5e8..5d3187ca 100644 --- a/app/renderer/css/preference.css +++ b/app/renderer/css/preference.css @@ -388,8 +388,7 @@ i.open-tab-button { .selected-css-path, .download-folder-path { background: #eeeeee; - padding: 10px; - margin-top: 10px; + padding: 5px 10px; margin-right: 10px; display: flex; width: 90%; @@ -565,7 +564,7 @@ input.toggle-round:checked+label:after { .certificate-input { width:100%; - margin-top: 10px; + margin-top: 10px; display:inline-flex; } diff --git a/app/renderer/js/components/handle-external-link.js b/app/renderer/js/components/handle-external-link.js index f6e58b41..2c88a5c3 100644 --- a/app/renderer/js/components/handle-external-link.js +++ b/app/renderer/js/components/handle-external-link.js @@ -10,19 +10,21 @@ function handleExternalLink(event) { const { url } = event; const domainPrefix = DomainUtil.getDomain(this.props.index).url; const downloadPath = ConfigUtil.getConfigItem('downloadsPath', `${app.getPath('downloads')}`); - // Whitelist URLs which are allowed to be opened in the app + const shouldShowInFolder = ConfigUtil.getConfigItem('showDownloadFolder', false); + + // Whitelist URLs which are allowed to be opened in the app const { - isInternalUrl: isWhiteListURL, - isUploadsUrl: isUploadsURL - } = LinkUtil.isInternal(domainPrefix, url); + isInternalUrl: isWhiteListURL, + isUploadsUrl: isUploadsURL + } = LinkUtil.isInternal(domainPrefix, url); if (isWhiteListURL) { event.preventDefault(); - // download txt, pdf, mp3, mp4 etc.. by using downloadURL in the - // main process which allows the user to save the files to their desktop - // and not trigger webview reload while image in webview will - // do nothing and will not save it + // download txt, pdf, mp3, mp4 etc.. by using downloadURL in the + // main process which allows the user to save the files to their desktop + // and not trigger webview reload while image in webview will + // do nothing and will not save it if (!LinkUtil.isImage(url) && isUploadsURL) { ipcRenderer.send('downloadFile', url, downloadPath); ipcRenderer.once('downloadFileCompleted', (event, filePath, fileName) => { @@ -37,7 +39,13 @@ function handleExternalLink(event) { } downloadNotification.onclick = () => { - shell.openItem(filePath); + if (shouldShowInFolder) { + // Reveal file in download folder + shell.showItemInFolder(filePath); + } else { + // Open file in the default native app + shell.openItem(filePath); + } }; ipcRenderer.removeAllListeners('downloadFileFailed'); }); @@ -51,7 +59,7 @@ function handleExternalLink(event) { return; } - // open internal urls inside the current webview. + // open internal urls inside the current webview. this.$el.loadURL(url); } else { event.preventDefault(); diff --git a/app/renderer/js/main.js b/app/renderer/js/main.js index 4d913aad..61031369 100644 --- a/app/renderer/js/main.js +++ b/app/renderer/js/main.js @@ -117,7 +117,8 @@ class ServerManagerView { showNotification: true, silent: false }, - downloadsPath: `${app.getPath('downloads')}` + downloadsPath: `${app.getPath('downloads')}`, + showDownloadFolder: false }; // Platform specific settings diff --git a/app/renderer/js/pages/preference/general-section.js b/app/renderer/js/pages/preference/general-section.js index 797a81ac..6c67ef62 100644 --- a/app/renderer/js/pages/preference/general-section.js +++ b/app/renderer/js/pages/preference/general-section.js @@ -97,6 +97,10 @@ class GeneralSection extends BaseSection {
Advanced
+
+
Show downloaded file in the file manager
+
+
Default download location @@ -108,6 +112,7 @@ class GeneralSection extends BaseSection {
${ConfigUtil.getConfigItem('downloadsPath', `${app.getPath('downloads')}`)}
+
Reset Application Data
@@ -138,6 +143,7 @@ class GeneralSection extends BaseSection { this.showCustomCSSPath(); this.removeCustomCSS(); this.downloadFolder(); + this.showDownloadFolder(); // Platform specific settings @@ -385,6 +391,18 @@ class GeneralSection extends BaseSection { }); } + showDownloadFolder() { + this.generateSettingOption({ + $element: document.querySelector('#show-download-folder .setting-control'), + value: ConfigUtil.getConfigItem('showDownloadFolder', false), + clickHandler: () => { + const newValue = !ConfigUtil.getConfigItem('showDownloadFolder'); + ConfigUtil.setConfigItem('showDownloadFolder', newValue); + this.showDownloadFolder(); + } + }); + } + } module.exports = GeneralSection;