mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 12:07:00 -04:00
pause and resume button
This commit is contained in:
parent
2d52bab3fe
commit
f5b7ce2c2c
@ -48,6 +48,8 @@ function getDownloadInfo(id) {
|
|||||||
d = createDict(DOWNLOAD_KEYS, values);
|
d = createDict(DOWNLOAD_KEYS, values);
|
||||||
if (d.status == "completed") {
|
if (d.status == "completed") {
|
||||||
clearInterval(downloadUpdaters[id]);
|
clearInterval(downloadUpdaters[id]);
|
||||||
|
Vue.delete(app.downloads, id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Vue.set(app.downloads, id, createDict(DOWNLOAD_KEYS, values));
|
Vue.set(app.downloads, id, createDict(DOWNLOAD_KEYS, values));
|
||||||
});
|
});
|
||||||
@ -87,6 +89,12 @@ function init() {
|
|||||||
eraseBook : function(book) {
|
eraseBook : function(book) {
|
||||||
contentManager.eraseBook(book.id);
|
contentManager.eraseBook(book.id);
|
||||||
},
|
},
|
||||||
|
pauseBook : function(book) {
|
||||||
|
contentManager.pauseBook(book.id);
|
||||||
|
},
|
||||||
|
resumeBook : function(book) {
|
||||||
|
contentManager.resumeBook(book.id);
|
||||||
|
},
|
||||||
displayedBooks : function(books, nb) {
|
displayedBooks : function(books, nb) {
|
||||||
var a = books.slice(0, nb);
|
var a = books.slice(0, nb);
|
||||||
return a;
|
return a;
|
||||||
@ -364,8 +372,10 @@ details:hover {
|
|||||||
{{ niceBytes(downloads[book.id].completedLength) }} / {{ niceBytes(downloads[book.id].totalLength) }}
|
{{ niceBytes(downloads[book.id].completedLength) }} / {{ niceBytes(downloads[book.id].totalLength) }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<button v-else-if="book.path" v-on:click="openBook(book)">Open</button>
|
<button v-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 && !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>
|
</span>
|
||||||
</summary>
|
</summary>
|
||||||
<p class="content">
|
<p class="content">
|
||||||
|
@ -203,6 +203,22 @@ void ContentManager::eraseBook(const QString& id)
|
|||||||
emit(mp_library->booksChanged());
|
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 ContentManager::getDownloadIds()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
@ -56,6 +56,8 @@ public slots:
|
|||||||
void setSearch(const QString& search);
|
void setSearch(const QString& search);
|
||||||
void eraseBook(const QString& id);
|
void eraseBook(const QString& id);
|
||||||
void updateRemoteLibrary(const QString& content);
|
void updateRemoteLibrary(const QString& content);
|
||||||
|
void pauseBook(const QString& id);
|
||||||
|
void resumeBook(const QString& id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTENTMANAGER_H
|
#endif // CONTENTMANAGER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user