mirror of
https://github.com/jely2002/youtube-dl-gui.git
synced 2021-11-01 22:46:21 +03:00
Implement the change download location button
This commit is contained in:
29
main.js
29
main.js
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user