Implement the change download location button

This commit is contained in:
Jelle Glebbeek
2021-02-06 02:43:20 +01:00
parent 115194132e
commit d11119754e
3 changed files with 33 additions and 2 deletions

29
main.js
View File

@@ -87,9 +87,36 @@ function createWindow () {
win.webContents.send("maximized", false)
});
let env = new Environment(process.platform, app.getAppPath(), app.getPath('home'), app.getPath('downloads'));
let env = new Environment(app);
let queryManager = new QueryManager(win, env);
//Show a dialog to select a folder, and return the selected value.
ipcMain.handle('downloadFolder', async (event) => {
await dialog.showOpenDialog(win, {
defaultPath: env.paths.downloadPath,
buttonLabel: "Set download location",
properties: [
'openDirectory',
'createDirectory'
]
}).then(result => {
if(result.filePaths[0] != null) env.paths.downloadPath = result.filePaths[0];
});
});
//Show a dialog to select a file, and return the selected value.
ipcMain.on('openFileDialog', async (event, filePath) => {
await dialog.showOpenDialog(win, {
defaultPath: filePath,
properties: [
'openFile',
'createDirectory'
]
}).then(result => {
event.sender.send('fileSelected', result.filePaths[0])
})
})
ipcMain.handle('videoAction', async (event, args) => {
console.log(args)
switch (args.action) {

View File

@@ -3,7 +3,7 @@ const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld(
"main", {
invoke: async (channel, data) => {
let validChannels = ["platform", "titlebarClick", "openInputMenu", "videoAction"];
let validChannels = ["platform", "titlebarClick", "openInputMenu", "videoAction", "downloadFolder"];
if (validChannels.includes(channel)) {
return await ipcRenderer.invoke(channel, data);
}

View File

@@ -105,6 +105,10 @@ async function init() {
$('#totalProgress small').html(`Downloading video queue - 0 of ${videos.length} completed`);
})
$('#locationBtn').on('click', () => {
window.main.invoke("downloadFolder");
});
$('#subtitleBtn').on('click', () => {
$('.video-cards').children().each(function () {
let identifier = this.id;