Fix JS alerts for msg state switching. Also make some github transfer tweaking.

This commit is contained in:
Martin Rotter 2016-06-22 09:38:28 +02:00
parent 3cba64fa56
commit 7ecda6be4d
7 changed files with 39 additions and 36 deletions

View File

@ -82,10 +82,10 @@
#define DEFAULT_ZOOM_FACTOR 1.0f
#define ZOOM_FACTOR_STEP 0.1f
#define INTERNAL_URL_MESSAGE "rssguard.message"
#define INTERNAL_URL_BLANK "rssguard.blank"
#define INTERNAL_URL_MESSAGE_HOST "message"
#define INTERNAL_URL_BLANK_HOST "blank"
#define INTERNAL_URL_MESSAGE "http://rssguard.message"
#define INTERNAL_URL_BLANK "http://rssguard.blank"
#define INTERNAL_URL_MESSAGE_HOST "rssguard.message"
#define INTERNAL_URL_BLANK_HOST "rssguard.blank"
#define FEED_INITIAL_OPML_PATTERN "feeds-%1.opml"

View File

@ -334,7 +334,7 @@ void FormMain::setupIcons() {
m_ui->m_actionAboutGuard->setIcon(icon_theme_factory->fromTheme(QSL("help-about")));
m_ui->m_actionCheckForUpdates->setIcon(icon_theme_factory->fromTheme(QSL("applications-internet")));
m_ui->m_actionCleanupDatabase->setIcon(icon_theme_factory->fromTheme(QSL("edit-clear")));
m_ui->m_actionReportBugGitHub->setIcon(icon_theme_factory->fromTheme(QSL("call-start")));
m_ui->m_actionReportBug->setIcon(icon_theme_factory->fromTheme(QSL("call-start")));
m_ui->m_actionBackupDatabaseSettings->setIcon(icon_theme_factory->fromTheme(QSL("document-export")));
m_ui->m_actionRestoreDatabaseSettings->setIcon(icon_theme_factory->fromTheme(QSL("document-import")));
m_ui->m_actionDonate->setIcon(icon_theme_factory->fromTheme(QSL("applications-office")));
@ -478,7 +478,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_actionReportBugGitHub, SIGNAL(triggered()), this, SLOT(reportABugOnGitHub()));
connect(m_ui->m_actionReportBug, SIGNAL(triggered()), this, SLOT(reportABug()));
connect(m_ui->m_actionDonate, SIGNAL(triggered()), this, SLOT(donate()));
connect(m_ui->m_actionDisplayWiki, SIGNAL(triggered()), this, SLOT(showWiki()));
@ -543,8 +543,8 @@ void FormMain::showAddAccountDialog() {
form_update->exec();
}
void FormMain::reportABugOnGitHub() {
if (!WebFactory::instance()->openUrlInExternalBrowser(STRFY(APP_URL_ISSUES_NEW_GITHUB))) {
void FormMain::reportABug() {
if (!WebFactory::instance()->openUrlInExternalBrowser(STRFY(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);

View File

@ -86,7 +86,7 @@ class FormMain : public QMainWindow {
void showUpdates();
void showWiki();
void showAddAccountDialog();
void reportABugOnGitHub();
void reportABug();
void donate();
private:

View File

@ -62,7 +62,7 @@
<string>&amp;Help</string>
</property>
<addaction name="m_actionCheckForUpdates"/>
<addaction name="m_actionReportBugGitHub"/>
<addaction name="m_actionReportBug"/>
<addaction name="m_actionDisplayWiki"/>
<addaction name="m_actionDonate"/>
<addaction name="m_actionAboutGuard"/>
@ -481,13 +481,10 @@
<string notr="true">M</string>
</property>
</action>
<action name="m_actionReportBugGitHub">
<action name="m_actionReportBug">
<property name="text">
<string>Report a &amp;bug...</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionSwitchToolBars">
<property name="checkable">

View File

@ -44,7 +44,8 @@ bool WebViewer::canDecreaseZoom() {
}
void WebViewer::displayMessage() {
setHtml(m_messageContents, QUrl(INTERNAL_URL_MESSAGE));
load(QUrl(INTERNAL_URL_MESSAGE));
//setHtml(m_messageContents, QUrl::fromUserInput("aa"));
}
bool WebViewer::increaseWebPageZoom() {

View File

@ -33,6 +33,10 @@ class WebViewer : public QWebEngineView {
bool canIncreaseZoom();
bool canDecreaseZoom();
inline QString messageContents() {
return m_messageContents;
}
public slots:
// Page zoom modifiers.
bool increaseWebPageZoom();

View File

@ -32,28 +32,23 @@ WebViewer *WebPage::view() const {
}
void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg) {
if (securityOrigin.isEmpty()) {
QStringList parts = msg.split(QL1C('-'));
QStringList parts = msg.split(QL1C('-'));
if (parts.size() == 2) {
int message_id = parts.at(0).toInt();
QString action = parts.at(1);
if (parts.size() == 2) {
int message_id = parts.at(0).toInt();
QString action = parts.at(1);
if (action == QSL("read")) {
emit messageStatusChangeRequested(message_id, MarkRead);
}
else if (action == QSL("unread")) {
emit messageStatusChangeRequested(message_id, MarkUnread);
}
else if (action == QSL("starred")) {
emit messageStatusChangeRequested(message_id, MarkStarred);
}
else if (action == QSL("unstarred")) {
emit messageStatusChangeRequested(message_id, MarkUnstarred);
}
else {
QWebEnginePage::javaScriptAlert(securityOrigin, msg);
}
if (action == QSL("read")) {
emit messageStatusChangeRequested(message_id, MarkRead);
}
else if (action == QSL("unread")) {
emit messageStatusChangeRequested(message_id, MarkUnread);
}
else if (action == QSL("starred")) {
emit messageStatusChangeRequested(message_id, MarkStarred);
}
else if (action == QSL("unstarred")) {
emit messageStatusChangeRequested(message_id, MarkUnstarred);
}
else {
QWebEnginePage::javaScriptAlert(securityOrigin, msg);
@ -65,5 +60,11 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg) {
}
bool WebPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) {
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
if (url.host() == INTERNAL_URL_MESSAGE_HOST) {
setHtml(view()->messageContents(), QUrl(INTERNAL_URL_MESSAGE));
return true;
}
else {
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
}
}