mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-06 04:14:22 +01:00
unify behavior when failed to open URL
This commit is contained in:
parent
5d6484a657
commit
0228ff8c68
@ -844,11 +844,7 @@ void FormMain::hideEvent(QHideEvent* event) {
|
||||
}
|
||||
|
||||
void FormMain::showDocs() {
|
||||
if (!qApp->web()->openUrlInExternalBrowser(APP_URL_DOCUMENTATION)) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(APP_URL_DOCUMENTATION);
|
||||
}
|
||||
|
||||
void FormMain::showAddAccountDialog() {
|
||||
@ -860,17 +856,9 @@ void FormMain::showAddAccountDialog() {
|
||||
}
|
||||
|
||||
void FormMain::reportABug() {
|
||||
if (!qApp->web()->openUrlInExternalBrowser(QSL(APP_URL_ISSUES_NEW))) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(QSL(APP_URL_ISSUES_NEW));
|
||||
}
|
||||
|
||||
void FormMain::donate() {
|
||||
if (!qApp->web()->openUrlInExternalBrowser(QSL(APP_DONATE_URL))) {
|
||||
qApp->showGuiMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning, this, true);
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(QSL(APP_DONATE_URL));
|
||||
}
|
||||
|
@ -237,11 +237,6 @@ void FormUpdate::startUpdate() {
|
||||
}
|
||||
else {
|
||||
// Self-update and package are not available.
|
||||
if (!qApp->web()->openUrlInExternalBrowser(url_file)) {
|
||||
qApp->showGuiMessage(tr("Cannot update application"),
|
||||
tr("Cannot navigate to installation file. Download new installation file manually on project website."),
|
||||
QSystemTrayIcon::MessageIcon::Warning,
|
||||
this, true);
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(url_file);
|
||||
}
|
||||
}
|
||||
|
@ -380,12 +380,7 @@ void MessagesView::openSelectedSourceMessagesExternally() {
|
||||
.m_url
|
||||
.replace(QRegularExpression("[\\t\\n]"), QString());
|
||||
|
||||
if (!qApp->web()->openUrlInExternalBrowser(link)) {
|
||||
qApp->showGuiMessage(tr("Problem with starting external web browser"),
|
||||
tr("External web browser could not be started."),
|
||||
QSystemTrayIcon::Critical);
|
||||
return;
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(link);
|
||||
}
|
||||
|
||||
// Finally, mark opened messages as read.
|
||||
|
@ -185,13 +185,7 @@ void WebBrowser::openCurrentSiteInSystemBrowser() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!qApp->web()->openUrlInExternalBrowser(url.toString())) {
|
||||
qApp->showGuiMessage(tr("Failed to open URL in web browser"),
|
||||
tr("URL '%1' could not be opened in system's web browser.").arg(url.toString()),
|
||||
QSystemTrayIcon::MessageIcon::Critical,
|
||||
qApp->mainFormWidget(),
|
||||
true);
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(url.toString());
|
||||
}
|
||||
|
||||
void WebBrowser::onTitleChanged(const QString& new_title) {
|
||||
|
@ -332,13 +332,5 @@ void OAuth2Service::retrieveAuthCode() {
|
||||
m_id);
|
||||
|
||||
// We run login URL in external browser, response is caught by light HTTP server.
|
||||
if (!qApp->web()->openUrlInExternalBrowser(auth_url)) {
|
||||
MessageBox::show(qApp->mainFormWidget(),
|
||||
QMessageBox::Icon::Question,
|
||||
tr("Navigate to website"),
|
||||
tr("To login, you need to navigate to the below website."),
|
||||
{},
|
||||
auth_url,
|
||||
QMessageBox::StandardButton::Ok);
|
||||
}
|
||||
qApp->web()->openUrlInExternalBrowser(auth_url);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "network-web/webfactory.h"
|
||||
|
||||
#include "gui/messagebox.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
@ -64,9 +65,9 @@ bool WebFactory::sendMessageViaEmail(const Message& message) {
|
||||
}
|
||||
|
||||
bool WebFactory::openUrlInExternalBrowser(const QString& url) const {
|
||||
qDebugNN << LOGSEC_NETWORK
|
||||
<< "We are trying to open URL:"
|
||||
<< QUOTE_W_SPACE_DOT(url);
|
||||
qDebugNN << LOGSEC_NETWORK << "We are trying to open URL" << QUOTE_W_SPACE_DOT(url);
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()) {
|
||||
const QString browser = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString();
|
||||
@ -75,17 +76,29 @@ bool WebFactory::openUrlInExternalBrowser(const QString& url) const {
|
||||
|
||||
qDebugNN << LOGSEC_NETWORK << "Arguments for external browser:" << QUOTE_W_SPACE_DOT(nice_args);
|
||||
|
||||
const bool result = IOFactory::startProcessDetached(browser, {}, nice_args);
|
||||
result = IOFactory::startProcessDetached(browser, {}, nice_args);
|
||||
|
||||
if (!result) {
|
||||
qDebugNN << LOGSEC_NETWORK << "External web browser call failed.";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return QDesktopServices::openUrl(url);
|
||||
result = QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
// We display GUI information that browser was not probably opened.
|
||||
MessageBox::show(qApp->mainFormWidget(),
|
||||
QMessageBox::Icon::Critical,
|
||||
tr("Navigate to website manually"),
|
||||
tr("%1 was unable to launch your web browser with the given URL, you need to open the "
|
||||
"below website URL in your web browser manually.").arg(APP_NAME),
|
||||
{},
|
||||
url,
|
||||
QMessageBox::StandardButton::Ok);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString WebFactory::stripTags(QString text) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user