mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 20:20:58 -04:00
delete a book closes all tabs opened of it
Before deleting a book, check all the tabs opened (except the first wich is the home tab and the last wich is the "new tab" button) and close those who have the same id of the book.
This commit is contained in:
parent
4ceccdc7df
commit
f371dbd15d
@ -218,6 +218,16 @@ void ContentManager::eraseBookFilesFromComputer(const QString fileToRemove)
|
||||
|
||||
void ContentManager::eraseBook(const QString& id)
|
||||
{
|
||||
auto tabBar = KiwixApp::instance()->getTabWidget();
|
||||
int i = 1;
|
||||
while (i < tabBar->count() - 1) {
|
||||
WebView* webView = tabBar->widget(i);
|
||||
if (webView->zimId() == id) {
|
||||
tabBar->closeTab(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
kiwix::Book book = mp_library->getBookById(id);
|
||||
QString fileToRemove = QString::fromUtf8(getLastPathElement(book.getPath()).c_str()) + "*";
|
||||
eraseBookFilesFromComputer(fileToRemove);
|
||||
|
Loading…
x
Reference in New Issue
Block a user