pause and resume button

This commit is contained in:
luddens 2019-04-25 15:06:56 +02:00
parent 2d52bab3fe
commit f5b7ce2c2c
3 changed files with 30 additions and 2 deletions

View File

@ -48,6 +48,8 @@ function getDownloadInfo(id) {
d = createDict(DOWNLOAD_KEYS, values);
if (d.status == "completed") {
clearInterval(downloadUpdaters[id]);
Vue.delete(app.downloads, id);
return;
}
Vue.set(app.downloads, id, createDict(DOWNLOAD_KEYS, values));
});
@ -87,6 +89,12 @@ function init() {
eraseBook : function(book) {
contentManager.eraseBook(book.id);
},
pauseBook : function(book) {
contentManager.pauseBook(book.id);
},
resumeBook : function(book) {
contentManager.resumeBook(book.id);
},
displayedBooks : function(books, nb) {
var a = books.slice(0, nb);
return a;
@ -364,8 +372,10 @@ details:hover {
{{ niceBytes(downloads[book.id].completedLength) }} / {{ niceBytes(downloads[book.id].totalLength) }}
</span>
</template>
<button v-else-if="book.path" v-on:click="openBook(book)">Open</button>
<button v-else v-on:click="downloadBook(book)">Download</button>
<button v-if="book.path" v-on:click="openBook(book)">Open</button>
<button v-if="!book.path && !downloads[book.id]" v-on:click="downloadBook(book)">Download</button>
<button v-if="downloads[book.id] && downloads[book.id].status == 'active'" v-on:click="pauseBook(book)">Pause</button>
<button v-if="downloads[book.id] && downloads[book.id].status == 'paused'" v-on:click="resumeBook(book)">Resume</button>
</span>
</summary>
<p class="content">

View File

@ -203,6 +203,22 @@ void ContentManager::eraseBook(const QString& id)
emit(mp_library->booksChanged());
}
void ContentManager::pauseBook(const QString& id)
{
auto& b = mp_library->getBookById(id);
auto download = mp_downloader->getDownload(b.getDownloadId());
if (download->getStatus() == kiwix::Download::K_ACTIVE)
download->pauseDownload();
}
void ContentManager::resumeBook(const QString& id)
{
auto& b = mp_library->getBookById(id);
auto download = mp_downloader->getDownload(b.getDownloadId());
if (download->getStatus() == kiwix::Download::K_PAUSED)
download->resumeDownload();
}
QStringList ContentManager::getDownloadIds()
{
QStringList list;

View File

@ -56,6 +56,8 @@ public slots:
void setSearch(const QString& search);
void eraseBook(const QString& id);
void updateRemoteLibrary(const QString& content);
void pauseBook(const QString& id);
void resumeBook(const QString& id);
};
#endif // CONTENTMANAGER_H