hmmmm.
This commit is contained in:
parent
f22f294eba
commit
a3a2f38c3e
11 changed files with 59 additions and 29 deletions
|
@ -46,6 +46,7 @@ set(FILE_VERSION "1,9,9,6")
|
|||
set(APP_AUTHOR "Martin Rotter")
|
||||
set(APP_URL "http://bitbucket.org/skunkos/rssguard")
|
||||
set(APP_URL_ISSUES "http://bitbucket.org/skunkos/rssguard/issues")
|
||||
set(APP_URL_ISSUES_NEW "http://bitbucket.org/skunkos/rssguard/issues/new")
|
||||
set(APP_EMAIL "rotter.martinos@gmail.com")
|
||||
set(MINIMUM_QT_VERSION 4.7.3)
|
||||
set(EXE_NAME ${APP_LOW_NAME})
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#define APP_EMAIL "@APP_EMAIL@"
|
||||
#define APP_URL "@APP_URL@"
|
||||
#define APP_URL_ISSUES "@APP_URL_ISSUES@"
|
||||
#define APP_URL_ISSUES_NEW "@APP_URL_ISSUES_NEW@"
|
||||
#define APP_VERSION "@APP_VERSION@"
|
||||
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + qWebKitVersion()
|
||||
|
||||
|
|
|
@ -24,31 +24,11 @@
|
|||
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
#include <QTextDocument>
|
||||
#include <QProcess>
|
||||
#include <QDesktopServices>
|
||||
|
||||
|
||||
NetworkFactory::NetworkFactory() {
|
||||
}
|
||||
|
||||
bool NetworkFactory::openUrlInExternalBrowser(const QString &url) {
|
||||
if (Settings::instance()->value(APP_CFG_BROWSER,
|
||||
"custom_external_browser",
|
||||
false).toBool()) {
|
||||
QString browser = Settings::instance()->value(APP_CFG_BROWSER,
|
||||
"external_browser_executable").toString();
|
||||
QString arguments = Settings::instance()->value(APP_CFG_BROWSER,
|
||||
"external_browser_arguments",
|
||||
"%1").toString();
|
||||
|
||||
return QProcess::startDetached(browser, QStringList() << arguments.arg(url));
|
||||
}
|
||||
else {
|
||||
return QDesktopServices::openUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
QString NetworkFactory::networkErrorText(QNetworkReply::NetworkError error_code) {
|
||||
switch (error_code) {
|
||||
case QNetworkReply::ProtocolUnknownError:
|
||||
|
|
|
@ -32,8 +32,6 @@ class NetworkFactory {
|
|||
explicit NetworkFactory();
|
||||
|
||||
public:
|
||||
static bool openUrlInExternalBrowser(const QString &url);
|
||||
|
||||
// Returns human readable text for given network error.
|
||||
static QString networkErrorText(QNetworkReply::NetworkError error_code);
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include <QApplication>
|
||||
#include <QRegExp>
|
||||
#include <QWebSettings>
|
||||
#include <QProcess>
|
||||
#include <QUrl>
|
||||
#include <QDesktopServices>
|
||||
|
||||
|
||||
QPointer<WebFactory> WebFactory::s_instance;
|
||||
|
@ -29,6 +32,23 @@ void WebFactory::loadState() {
|
|||
false);
|
||||
}
|
||||
|
||||
bool WebFactory::openUrlInExternalBrowser(const QString &url) {
|
||||
if (Settings::instance()->value(APP_CFG_BROWSER,
|
||||
"custom_external_browser",
|
||||
false).toBool()) {
|
||||
QString browser = Settings::instance()->value(APP_CFG_BROWSER,
|
||||
"external_browser_executable").toString();
|
||||
QString arguments = Settings::instance()->value(APP_CFG_BROWSER,
|
||||
"external_browser_arguments",
|
||||
"%1").toString();
|
||||
|
||||
return QProcess::startDetached(browser, QStringList() << arguments.arg(url));
|
||||
}
|
||||
else {
|
||||
return QDesktopServices::openUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
void WebFactory::switchJavascript(bool enable, bool save_settings) {
|
||||
if (save_settings) {
|
||||
Settings::instance()->setValue(APP_CFG_BROWSER,
|
||||
|
|
|
@ -28,15 +28,19 @@ class WebFactory : public QObject {
|
|||
QString escapeHtml(const QString &html);
|
||||
QString deEscapeHtml(const QString &text);
|
||||
|
||||
// Singleton getter.
|
||||
static WebFactory *instance();
|
||||
|
||||
public slots:
|
||||
// Operations.
|
||||
// Switchers.
|
||||
bool javascriptEnabled() const;
|
||||
bool pluginsEnabled() const;
|
||||
bool autoloadImages() const;
|
||||
|
||||
// Singleton getter.
|
||||
static WebFactory *instance();
|
||||
|
||||
public slots:
|
||||
// Opens given string URL in external browser.
|
||||
bool openUrlInExternalBrowser(const QString &url);
|
||||
|
||||
// Switchers.
|
||||
void switchJavascript(bool enable, bool save_settings = true);
|
||||
void switchPlugins(bool enable, bool save_settings = true);
|
||||
void switchImages(bool enable, bool save_settings = true);
|
||||
|
|
|
@ -384,6 +384,7 @@ void FormMain::createConnections() {
|
|||
// Menu "Help" connections.
|
||||
connect(m_ui->m_actionAboutGuard, SIGNAL(triggered()), this, SLOT(showAbout()));
|
||||
connect(m_ui->m_actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(showUpdates()));
|
||||
connect(m_ui->m_actionReportBug, SIGNAL(triggered()), this, SLOT(reportABug()));
|
||||
|
||||
// General connections.
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
|
||||
|
@ -478,6 +479,22 @@ void FormMain::showUpdates() {
|
|||
SystemFactory::instance()->applicationCloseLock()->unlock();
|
||||
}
|
||||
|
||||
void FormMain::reportABug() {
|
||||
if (!WebFactory::instance()->openUrlInExternalBrowser(APP_URL_ISSUES_NEW)) {
|
||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||
SystemTrayIcon::instance()->showMessage(tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."),
|
||||
QSystemTrayIcon::Warning);
|
||||
}
|
||||
else {
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Warning,
|
||||
tr("Cannot open external browser"),
|
||||
tr("Cannot open external browser. Navigate to application website manually."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FormMain::showSettings() {
|
||||
QPointer<FormSettings> form_pointer = new FormSettings(this);
|
||||
form_pointer.data()->exec();
|
||||
|
|
|
@ -113,6 +113,7 @@ class FormMain : public QMainWindow {
|
|||
void showSettings();
|
||||
void showAbout();
|
||||
void showUpdates();
|
||||
void reportABug();
|
||||
|
||||
private:
|
||||
Ui::FormMain *m_ui;
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="m_actionCheckForUpdates"/>
|
||||
<addaction name="m_actionReportBug"/>
|
||||
<addaction name="m_actionAboutGuard"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuView">
|
||||
|
@ -491,6 +492,11 @@
|
|||
<string>Auto-load &images</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionReportBug">
|
||||
<property name="text">
|
||||
<string>Report a &bug...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "core/defs.h"
|
||||
#include "core/systemfactory.h"
|
||||
#include "core/networkfactory.h"
|
||||
#include "core/webfactory.h"
|
||||
#include "gui/iconthemefactory.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
|
@ -117,7 +118,7 @@ void FormUpdate::startUpdate() {
|
|||
url_file = APP_URL;
|
||||
}
|
||||
|
||||
if (!NetworkFactory::openUrlInExternalBrowser(url_file)) {
|
||||
if (!WebFactory::instance()->openUrlInExternalBrowser(url_file)) {
|
||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||
SystemTrayIcon::instance()->showMessage(tr("Cannot update application"),
|
||||
tr("Cannot navigate to installation file. Check new installation downloads "
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "core/messagesmodel.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/networkfactory.h"
|
||||
#include "core/webfactory.h"
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/messagebox.h"
|
||||
|
||||
|
@ -243,7 +244,7 @@ void MessagesView::openSelectedSourceArticlesExternally() {
|
|||
foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
|
||||
QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
|
||||
|
||||
if (!NetworkFactory::openUrlInExternalBrowser(link)) {
|
||||
if (!WebFactory::instance()->openUrlInExternalBrowser(link)) {
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Critical,
|
||||
tr("Problem with starting external web browser"),
|
||||
|
|
Loading…
Add table
Reference in a new issue