mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 03:58:56 -04:00
Introduced showConfirmBox()
This commit is contained in:
parent
c07838806b
commit
0f088697c6
@ -538,14 +538,8 @@ void ContentManager::eraseBook(const QString& id)
|
|||||||
text += formatText(gt("perma-delete-files-text"));
|
text += formatText(gt("perma-delete-files-text"));
|
||||||
}
|
}
|
||||||
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
|
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
|
||||||
KiwixConfirmBox *dialog = new KiwixConfirmBox(gt("delete-book"), text, false, mp_view);
|
showConfirmBox(gt("delete-book"), text, mp_view, [=]() {
|
||||||
dialog->show();
|
|
||||||
connect(dialog, &KiwixConfirmBox::yesClicked, [=]() {
|
|
||||||
reallyEraseBook(id, moveToTrash);
|
reallyEraseBook(id, moveToTrash);
|
||||||
dialog->deleteLater();
|
|
||||||
});
|
|
||||||
connect(dialog, &KiwixConfirmBox::noClicked, [=]() {
|
|
||||||
dialog->deleteLater();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,15 +581,9 @@ void ContentManager::cancelBook(const QString& id, QModelIndex index)
|
|||||||
{
|
{
|
||||||
auto text = gt("cancel-download-text");
|
auto text = gt("cancel-download-text");
|
||||||
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
|
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getTitle()));
|
||||||
KiwixConfirmBox *dialog = new KiwixConfirmBox(gt("cancel-download"), text, false, mp_view);
|
showConfirmBox(gt("cancel-download"), text, mp_view, [=]() {
|
||||||
dialog->show();
|
|
||||||
connect(dialog, &KiwixConfirmBox::yesClicked, [=]() {
|
|
||||||
cancelBook(id);
|
cancelBook(id);
|
||||||
emit managerModel->cancelDownload(index);
|
emit managerModel->cancelDownload(index);
|
||||||
dialog->deleteLater();
|
|
||||||
});
|
|
||||||
connect(dialog, &KiwixConfirmBox::noClicked, [=]() {
|
|
||||||
dialog->deleteLater();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +29,19 @@ private:
|
|||||||
|
|
||||||
void showInfoBox(QString title, QString text, QWidget *parent = nullptr);
|
void showInfoBox(QString title, QString text, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
template<class YesAction>
|
||||||
|
void showConfirmBox(QString title, QString text, QWidget *parent,
|
||||||
|
YesAction yesAction)
|
||||||
|
{
|
||||||
|
KiwixConfirmBox *dialog = new KiwixConfirmBox(title, text, false, parent);
|
||||||
|
dialog->show();
|
||||||
|
QObject::connect(dialog, &KiwixConfirmBox::yesClicked, [=]() {
|
||||||
|
yesAction();
|
||||||
|
dialog->deleteLater();
|
||||||
|
});
|
||||||
|
QObject::connect(dialog, &KiwixConfirmBox::noClicked, [=]() {
|
||||||
|
dialog->deleteLater();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#endif // KIWIXCONFIRMBOX_H
|
#endif // KIWIXCONFIRMBOX_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user