dock: show client progress
This commit is contained in:
18
index.js
18
index.js
@@ -58,6 +58,11 @@ electron.ipcMain.on('setAspectRatio', function (e, aspectRatio, extraSize) {
|
|||||||
setAspectRatio(aspectRatio, extraSize)
|
setAspectRatio(aspectRatio, extraSize)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
electron.ipcMain.on('setProgress', function (e, progress) {
|
||||||
|
setProgress(progress)
|
||||||
|
})
|
||||||
|
|
||||||
function createMainWindow () {
|
function createMainWindow () {
|
||||||
var win = new electron.BrowserWindow({
|
var win = new electron.BrowserWindow({
|
||||||
backgroundColor: '#282828',
|
backgroundColor: '#282828',
|
||||||
@@ -118,6 +123,13 @@ function setAspectRatio (aspectRatio, extraSize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show progress bar. Valid range is [0, 1]. Remove when < 0; indeterminate when > 1.
|
||||||
|
function setProgress (progress) {
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.setProgressBar(progress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleDevTools (win) {
|
function toggleDevTools (win) {
|
||||||
debug('toggleDevTools')
|
debug('toggleDevTools')
|
||||||
win = win || electron.BrowserWindow.getFocusedWindow()
|
win = win || electron.BrowserWindow.getFocusedWindow()
|
||||||
@@ -334,9 +346,3 @@ if (process.platform === 'darwin') {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// var progress = 0
|
|
||||||
// setInterval(function () {
|
|
||||||
// progress += 0.1
|
|
||||||
// mainWindow.setProgressBar(progress)
|
|
||||||
// }, 1000)
|
|
||||||
|
|||||||
@@ -74,6 +74,19 @@ function update () {
|
|||||||
var patches = diff(currentVDom, newVDom)
|
var patches = diff(currentVDom, newVDom)
|
||||||
rootElement = patch(rootElement, patches)
|
rootElement = patch(rootElement, patches)
|
||||||
currentVDom = newVDom
|
currentVDom = newVDom
|
||||||
|
|
||||||
|
updateDockIcon()
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateDockIcon () {
|
||||||
|
if (state.view.client) {
|
||||||
|
var progress = state.view.client.progress
|
||||||
|
// Hide progress bar when client has no torrents, or progress is 100%
|
||||||
|
if (state.view.client.torrents.length === 0 || progress === 1) {
|
||||||
|
progress = -1
|
||||||
|
}
|
||||||
|
electron.ipcRenderer.send('setProgress', progress)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user