mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Merge pull request #744 from kiwix/handling_of_NoEntry_in_openRandomUrl
Handling of NoEntry in KiwixApp::openRandomUrl()
This commit is contained in:
commit
1d49c2ebc3
@ -11,6 +11,7 @@
|
||||
"open-zim":"Open Zim",
|
||||
"local-kiwix-server":"Local Kiwix Server",
|
||||
"random-article":"Random Article",
|
||||
"random-article-error":"Failed to open a random article.",
|
||||
"home-page":"Home page",
|
||||
"main-menu":"Main menu",
|
||||
"print":"Print",
|
||||
|
@ -17,6 +17,7 @@
|
||||
"open-zim": "Открыть Zim",
|
||||
"local-kiwix-server": "Локальный сервер Kiwix",
|
||||
"random-article": "Случайная статья",
|
||||
"random-article-error":"Не удалось открыть случайную статью.",
|
||||
"home-page": "Домашняя страница",
|
||||
"main-menu": "Главное меню",
|
||||
"print": "Печать",
|
||||
|
@ -249,13 +249,17 @@ void KiwixApp::openRandomUrl(bool newTab)
|
||||
return;
|
||||
}
|
||||
auto reader = m_library.getReader(zimId);
|
||||
auto entry = reader->getRandomPage();
|
||||
try {
|
||||
auto entry = reader->getRandomPage();
|
||||
|
||||
QUrl url;
|
||||
url.setScheme("zim");
|
||||
url.setHost(zimId + ".zim");
|
||||
url.setPath("/" + QString::fromStdString(entry.getPath()));
|
||||
openUrl(url, newTab);
|
||||
QUrl url;
|
||||
url.setScheme("zim");
|
||||
url.setHost(zimId + ".zim");
|
||||
url.setPath("/" + QString::fromStdString(entry.getPath()));
|
||||
openUrl(url, newTab);
|
||||
} catch ( const kiwix::NoEntry& ) {
|
||||
showMessage(gt("random-article-error"));
|
||||
}
|
||||
}
|
||||
|
||||
void KiwixApp::showMessage(const QString &message)
|
||||
|
Loading…
x
Reference in New Issue
Block a user