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",
|
"home-page":"Home page",
|
||||||
"main-menu":"Main menu",
|
"main-menu":"Main menu",
|
||||||
"print":"Print",
|
"print":"Print",
|
||||||
|
"print-page-error": "An error has occured while printing.",
|
||||||
"new-tab":"New tab",
|
"new-tab":"New tab",
|
||||||
"close-tab":"Close tab",
|
"close-tab":"Close tab",
|
||||||
"close":"Close",
|
"close":"Close",
|
||||||
|
@ -128,13 +128,8 @@ void ContentManager::openBook(const QString &id)
|
|||||||
tabBar->closeTab(1);
|
tabBar->closeTab(1);
|
||||||
auto text = gt("zim-open-fail-text");
|
auto text = gt("zim-open-fail-text");
|
||||||
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getPath()));
|
text = text.replace("{{ZIM}}", QString::fromStdString(mp_library->getBookById(id).getPath()));
|
||||||
QMessageBox msgBox(
|
auto title = gt("zim-open-fail-title");
|
||||||
QMessageBox::Warning, //Icon
|
KiwixApp::instance()->showMessage(text, title, QMessageBox::Warning);
|
||||||
gt("zim-open-fail-title"), //Title
|
|
||||||
text, //Text
|
|
||||||
QMessageBox::Ok //Buttons
|
|
||||||
);
|
|
||||||
msgBox.exec();
|
|
||||||
mp_library->removeBookFromLibraryById(id);
|
mp_library->removeBookFromLibraryById(id);
|
||||||
tabBar->setCurrentIndex(0);
|
tabBar->setCurrentIndex(0);
|
||||||
emit(booksChanged());
|
emit(booksChanged());
|
||||||
|
@ -178,13 +178,7 @@ void KiwixApp::openZimFile(const QString &zimfile)
|
|||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
auto text = gt("zim-open-fail-text");
|
auto text = gt("zim-open-fail-text");
|
||||||
text = text.replace("{{ZIM}}", validZimFile);
|
text = text.replace("{{ZIM}}", validZimFile);
|
||||||
QMessageBox msgBox(
|
showMessage(text, gt("zim-open-fail-title"), QMessageBox::Warning);
|
||||||
QMessageBox::Warning, //Icon
|
|
||||||
gt("zim-open-fail-title"), //Title
|
|
||||||
text, //Text
|
|
||||||
QMessageBox::Ok //Buttons
|
|
||||||
);
|
|
||||||
msgBox.exec();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openUrl(QUrl("zim://"+zimId+".zim/"));
|
openUrl(QUrl("zim://"+zimId+".zim/"));
|
||||||
@ -204,7 +198,7 @@ void KiwixApp::printPage()
|
|||||||
return;
|
return;
|
||||||
webview->page()->print(printer, [=](bool success) {
|
webview->page()->print(printer, [=](bool success) {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
showMessage("An error has occured while printing.");
|
showMessage(gt("print-page-error"), gt("error-title"), QMessageBox::Critical);
|
||||||
}
|
}
|
||||||
delete printer;
|
delete printer;
|
||||||
});
|
});
|
||||||
@ -235,13 +229,19 @@ void KiwixApp::openRandomUrl(bool newTab)
|
|||||||
url.setPath("/" + QString::fromStdString(entry.getPath()));
|
url.setPath("/" + QString::fromStdString(entry.getPath()));
|
||||||
openUrl(url, newTab);
|
openUrl(url, newTab);
|
||||||
} catch ( const kiwix::NoEntry& ) {
|
} 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)
|
QAction *KiwixApp::getAction(KiwixApp::Actions action)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <QtSingleApplication>
|
#include <QtSingleApplication>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <kiwix/name_mapper.h>
|
#include <kiwix/name_mapper.h>
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ public:
|
|||||||
|
|
||||||
void openRandomUrl(bool newTab=true);
|
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; }
|
KProfile* getProfile() { return &m_profile; }
|
||||||
Library* getLibrary() { return &m_library; }
|
Library* getLibrary() { return &m_library; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user