mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Update showMessage()
This removes the previous default error message. KiwixApp::showMessage() now accepts title, text and MessageBox icon
This commit is contained in:
parent
f14d633fd3
commit
90afbf3f92
@ -15,6 +15,7 @@
|
||||
"home-page":"Home page",
|
||||
"main-menu":"Main menu",
|
||||
"print":"Print",
|
||||
"print-page-error": "An error has occured while printing.",
|
||||
"new-tab":"New tab",
|
||||
"close-tab":"Close tab",
|
||||
"close":"Close",
|
||||
|
@ -128,13 +128,8 @@ void ContentManager::openBook(const QString &id)
|
||||
tabBar->closeTab(1);
|
||||
auto text = gt("zim-open-fail-text");
|
||||
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getPath()));
|
||||
QMessageBox msgBox(
|
||||
QMessageBox::Warning, //Icon
|
||||
gt("zim-open-fail-title"), //Title
|
||||
text, //Text
|
||||
QMessageBox::Ok //Buttons
|
||||
);
|
||||
msgBox.exec();
|
||||
auto title = gt("zim-open-fail-title");
|
||||
KiwixApp::instance()->showMessage(text, title, QMessageBox::Warning);
|
||||
mp_library->removeBookFromLibraryById(id);
|
||||
tabBar->setCurrentIndex(0);
|
||||
emit(booksChanged());
|
||||
|
@ -178,13 +178,7 @@ void KiwixApp::openZimFile(const QString &zimfile)
|
||||
} catch (const std::exception& e) {
|
||||
auto text = gt("zim-open-fail-text");
|
||||
text = text.replace("{{ZIM}}", validZimFile);
|
||||
QMessageBox msgBox(
|
||||
QMessageBox::Warning, //Icon
|
||||
gt("zim-open-fail-title"), //Title
|
||||
text, //Text
|
||||
QMessageBox::Ok //Buttons
|
||||
);
|
||||
msgBox.exec();
|
||||
showMessage(text, gt("zim-open-fail-title"), QMessageBox::Warning);
|
||||
return;
|
||||
}
|
||||
openUrl(QUrl("zim://"+zimId+".zim/"));
|
||||
@ -204,7 +198,7 @@ void KiwixApp::printPage()
|
||||
return;
|
||||
webview->page()->print(printer, [=](bool success) {
|
||||
if (!success) {
|
||||
showMessage("An error has occured while printing.");
|
||||
showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical);
|
||||
}
|
||||
delete printer;
|
||||
});
|
||||
@ -235,13 +229,19 @@ void KiwixApp::openRandomUrl(bool newTab)
|
||||
url.setPath("/" + QString::fromStdString(entry.getPath()));
|
||||
openUrl(url, newTab);
|
||||
} catch ( const kiwix::NoEntry& ) {
|
||||
showMessage(gt("random-article-error"));
|
||||
showMessage(gt("random-article-error"), gt("error-title"), QMessageBox::Information);
|
||||
}
|
||||
}
|
||||
|
||||
void KiwixApp::showMessage(const QString &message)
|
||||
void KiwixApp::showMessage(const QString &message, const QString &title, const enum QMessageBox::Icon &icon)
|
||||
{
|
||||
mp_errorDialog->showMessage(message);
|
||||
QMessageBox msgBox(
|
||||
icon, //Icon
|
||||
title, //Title
|
||||
message, //Text
|
||||
QMessageBox::Ok //Buttons
|
||||
);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
QAction *KiwixApp::getAction(KiwixApp::Actions action)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <QtSingleApplication>
|
||||
#include <QApplication>
|
||||
#include <QErrorMessage>
|
||||
#include <QMessageBox>
|
||||
#include <QTranslator>
|
||||
#include <kiwix/name_mapper.h>
|
||||
|
||||
@ -66,7 +67,7 @@ public:
|
||||
|
||||
void openRandomUrl(bool newTab=true);
|
||||
|
||||
void showMessage(const QString& message);
|
||||
void showMessage(const QString& message, const QString& title, const enum QMessageBox::Icon& icon);
|
||||
|
||||
KProfile* getProfile() { return &m_profile; }
|
||||
Library* getLibrary() { return &m_library; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user