Skip to content

Commit

Permalink
Merge pull request #11 from jely2002/1.7.2
Browse files Browse the repository at this point in the history
v1.7.4
  • Loading branch information
jely2002 authored Sep 3, 2020
2 parents f7921cd + 839b777 commit 47c5013
Show file tree
Hide file tree
Showing 15 changed files with 438 additions and 203 deletions.
39 changes: 35 additions & 4 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ body {
padding: 10px 30px;
}

.menubar {
display: none !important;
}

.main-input {
background-color: #303030;
padding: 30px;
Expand Down Expand Up @@ -63,6 +59,7 @@ body {

.bs-stepper {
width: 100%;
margin-top: 40px !important;
}

.bs-stepper .line {
Expand Down Expand Up @@ -227,3 +224,37 @@ input[type="search"]::-webkit-search-cancel-button {
font-size: 80%;
display: none;
}

.windowbar.fixed {
top: 0 !important;
width: 100% !important;
background-color: black !important;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}

.windowbar-title {
font-size: 13px !important;
line-height: 14px;
}

.windowbar-icon {
position: relative;
max-width: 25px;
margin-left: 10px;
margin-bottom: -2px;
}

.windowbar-maximize:hover {
background-color: black !important;
}

svg.maximize-svg path {
fill: rgba(255,255,255,0.2) !important;
}

svg.unmaximize-svg {
display: none !important;
}
19 changes: 15 additions & 4 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'">
<title>Youtube Downloader</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bs-stepper/dist/css/bs-stepper.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bs-stepper/dist/css/bs-stepper.min.css" integrity="sha384-qMhYxsMd/tIFRNt3QjOFfDoDdMUCWR5v2sCzrB3MPbZqs5Osdq41JCmLJJPURa+o" crossorigin="anonymous">
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="main.css" crossorigin="anonymous">
</head>
Expand Down Expand Up @@ -183,6 +184,16 @@
The download is taking longer than usual, this might be because you're downloading a large file, have a slow connection, or are downloading subtitles. Otherwise please restart the program.
</div>
</div>
<div class="toast warning-toast" id="update" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header bg-success">
<i class="fas mr-3 fa-download"></i>
<strong class="mr-auto">There is an update available!</strong>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="toast-body" onclick="shell.openExternal('https://github.com/jely2002/youtube-dl-gui/releases/latest')"></div>
</div>
<div class="modal fade" id="cookiesModal" tabindex="-1" role="dialog" aria-labelledby="cookiesModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
Expand Down Expand Up @@ -241,13 +252,13 @@ <h5 class="modal-title" id="credentialsModalLabel">Add credentials</h5>
</div>
</div>
</div>
<script src="modules/caching.js"></script>
<script src="modules/controller.js"></script>
<script src="modules/UI.js"></script>
<script src="modules/video.js"></script>
<script src="modules/playlist.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bs-stepper.min.js" integrity="sha256-INfYp5owpb0btFquNHGlhSxgGYrFlGYRU2oN/3jWGeM=" crossorigin="anonymous"></script>
<script src="modules/caching.js"></script>
<script src="web-resources/bootstrap.min.js"></script>
<script src="web-resources/bs-stepper.min.js"></script>
<script src="modules/metrics.js"></script>
<script src="modules/updater.js"></script>
</body>
Expand Down
127 changes: 103 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain, nativeImage } = require('electron')
const { app, BrowserWindow, ipcMain, nativeImage, dialog, Menu} = require('electron')
const { autoUpdater } = require("electron-updater")
const fs = require('fs')
const mkdirp = require('mkdirp')
Expand Down Expand Up @@ -36,7 +36,6 @@ if(process.platform === "linux") {
})
}


let win

//Create the window for the renderer process
Expand All @@ -46,27 +45,31 @@ function createWindow () {
win = new BrowserWindow({
show: false,
width: 800, //850
height: 500, //550
height: 510, //550
resizable: false,
maximizable: false,
titleBarStyle: "hidden",
icon: "web-resources/icon-light.png",
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
enableRemoteModule: false,
worldSafeExecuteJavaScript: true
}
})
} else {
autoUpdater.checkForUpdatesAndNotify();
win = new BrowserWindow({
show: false,
width: 800, //850
height: 530, //550
height: 540, //550
resizable: false,
maximizable: false,
frame: false,
icon: "web-resources/icon-light.png",
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
enableRemoteModule: false,
worldSafeExecuteJavaScript: true
}
})
}
Expand All @@ -78,29 +81,19 @@ function createWindow () {
win.on('closed', () => {
win = null
})

win.once('ready-to-show', () => {
win.show()
})
}

app.on('ready', () => {
/*app.setLoginItemSettings({ TODO Sync playlists on startup
openAtLogin: false,
openAsHidden: true,
args: [
'--startup'
]
})
if(process.argv.includes('startup')) {
startUpdate(() => {
app.quit()
})
} else {
createWindow()
}*/
createWindow()
if(process.platform === "darwin" && process.argv[2] !== '--dev') {
autoUpdater.checkForUpdates().then((result) => {
result.currentVersion = app.getVersion();
win.webContents.send('mac-update', result)
})
}
})

//Quit the application when all windows are closed, except for darwin
Expand All @@ -112,14 +105,14 @@ app.on('window-all-closed', () => {

//Create a window when there is none, but the app is still active (darwin)
app.on('activate', () => {
if (win === null /*&& !process.argv.includes('startup') TODO Sync playlists on startup*/) {
if (win === null) {
createWindow()
}
});


//Event handler to process icon updates from the renderer process
ipcMain.on('request-mainprocess-action', (event, arg) => {
ipcMain.handle('setOverlayIcon', (event, arg) => {
if(arg.mode === "hide") {
win.setOverlayIcon(null, "")
} else if(arg.mode === "downloading") {
Expand All @@ -128,3 +121,89 @@ ipcMain.on('request-mainprocess-action', (event, arg) => {
win.setOverlayIcon(doneIcon, "done")
}
})

//Creates the input menu to show on right click
const InputMenu = Menu.buildFromTemplate(
[{
label: 'Cut',
role: 'cut',
}, {
label: 'Copy',
role: 'copy',
}, {
label: 'Paste',
role: 'paste',
}, {
type: 'separator',
}, {
label: 'Select all',
role: 'selectall',
},
]);

//Opens the input menu when ordered from renderer process
ipcMain.handle('openInputMenu', () => {
InputMenu.popup(win);
})

//Update the progressbar when ordered from renderer process
ipcMain.handle('updateProgressBar', async (event, arg) => {
if(arg === "hide") {
await win.setProgressBar(-1, {mode: "none"})
} else if(arg === "indeterminate") {
win.setProgressBar(2, {mode: "indeterminate"})
} else {
await win.setProgressBar(arg)
}
})


//Show a dialog to select a folder, and return the selected value.
ipcMain.on('openFolderDialog', async (event, selectedPath) => {
await dialog.showOpenDialog(win, {
defaultPath: selectedPath,
properties: [
'openDirectory',
'createDirectory'
]
}).then(result => {
event.sender.send('directorySelected', 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('getPath', (event, arg) => {
if(arg === "appPath") {
return app.getAppPath()
} else {
return app.getPath(arg)
}
})

ipcMain.handle('appInfo', async (event, arg) => {
if(arg === "version") {
return app.getVersion()
} else if(arg === "country") {
return app.getLocaleCountryCode()
}
})

ipcMain.handle('titlebarClick', (event, arg) => {
if(arg === 'close') {
win.close()
} else if(arg === "minimize") {
win.minimize()
}
})
Loading

0 comments on commit 47c5013

Please sign in to comment.