Merge branch 'webengine'

This commit is contained in:
Jeena 2015-10-13 20:08:48 +02:00
commit 342b1d6a3d
6 changed files with 23 additions and 28 deletions

View file

@ -1,7 +1,7 @@
TARGET = feedthemonkey TARGET = feedthemonkey
TEMPLATE = app TEMPLATE = app
QT += qml quick QT += qml quick webenginewidgets
CONFIG += c++11 CONFIG += c++11
SOURCES += \ SOURCES += \

View file

@ -2,13 +2,13 @@
pkgname=feedthemonkey pkgname=feedthemonkey
_name=FeedTheMonkey _name=FeedTheMonkey
pkgver=2.0.0 pkgver=2.1.0
pkgrel=1 pkgrel=1
pkgdesc="Desktop client for the TinyTinyRSS reader" pkgdesc="Desktop client for the TinyTinyRSS reader"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')
url="http://jabs.nu/feedthemonkey" url="http://jabs.nu/feedthemonkey"
license=('BSD') license=('BSD')
depends=('qt5-declarative' 'qt5-quick1' 'qt5-quickcontrols' 'qt5-webkit') depends=('qt5-declarative' 'qt5-quick1' 'qt5-quickcontrols' 'qt5-webengine')
source=("https://github.com/jeena/${_name}/archive/v${pkgver}.tar.gz") source=("https://github.com/jeena/${_name}/archive/v${pkgver}.tar.gz")
md5sums=('SKIP') md5sums=('SKIP')

View file

@ -1,5 +1,4 @@
import QtWebKit 3.0 import QtWebEngine 1.0
import QtWebKit.experimental 1.0
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.3 import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
@ -7,7 +6,7 @@ import QtQuick.Controls.Styles 1.3
import QtQuick.Controls 1.3 import QtQuick.Controls 1.3
import TTRSS 1.0 import TTRSS 1.0
ScrollView { Item {
id: content id: content
property Post post property Post post
property ApplicationWindow app property ApplicationWindow app
@ -18,23 +17,19 @@ ScrollView {
Layout.minimumWidth: 400 Layout.minimumWidth: 400
onTextFontSizeChanged: webView.setDefaults() onTextFontSizeChanged: webView.setDefaults()
style: ScrollViewStyle {
transientScrollBars: true
}
function scrollDown(jump) { function scrollDown(jump) {
if(!jump) { if(!jump) {
webView.experimental.evaluateJavaScript("window.scrollTo(0, document.body.scrollHeight - " + height + ");") webView.runJavaScript("window.scrollTo(0, document.body.scrollHeight - " + height + ");")
} else { } else {
webView.experimental.evaluateJavaScript("window.scrollBy(0, " + jump + ");") webView.runJavaScript("window.scrollBy(0, " + jump + ");")
} }
} }
function scrollUp(jump) { function scrollUp(jump) {
if(!jump) { if(!jump) {
webView.experimental.evaluateJavaScript("window.scrollTo(0, 0);") webView.runJavaScript("window.scrollTo(0, 0);")
} else { } else {
webView.experimental.evaluateJavaScript("window.scrollBy(0, -" + jump + ");") webView.runJavaScript("window.scrollBy(0, -" + jump + ");")
} }
} }
@ -44,41 +39,39 @@ ScrollView {
Label { id: fontLabel } Label { id: fontLabel }
WebView { WebEngineView {
id: webView id: webView
anchors.fill: parent
url: "../html/content.html" url: "../html/content.html"
// Enable communication between QML and WebKit
experimental.preferences.navigatorQtObjectEnabled: true;
property Post post: content.post property Post post: content.post
function setPost() { function setPost() {
if(post) { if(post) {
experimental.evaluateJavaScript("setArticle(" + post.jsonString + ")") runJavaScript("setArticle(" + post.jsonString + ")")
} else { } else {
experimental.evaluateJavaScript("setArticle('logout')") runJavaScript("setArticle('logout')")
} }
} }
function setDefaults() { function setDefaults() {
// font name needs to be enclosed in single quotes // font name needs to be enclosed in single quotes
experimental.evaluateJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'\";"); runJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'\";");
experimental.evaluateJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';"); runJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';");
} }
onNavigationRequested: { onNavigationRequested: {
if (request.navigationType != WebView.LinkClickedNavigation) { if (request.navigationType != WebEngineView.LinkClickedNavigation) {
request.action = WebView.AcceptRequest; request.action = WebEngineView.AcceptRequest;
} else { } else {
request.action = WebView.IgnoreRequest; request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.url); Qt.openUrlExternally(request.url);
} }
} }
onLoadingChanged: { onLoadingChanged: {
if(loadRequest.status === WebView.LoadSucceededStatus) { if(!loading) {
setPost() setPost()
setDefaults() setDefaults()
} }

View file

@ -63,7 +63,7 @@ ScrollView {
} }
item.content.post = server.posts[currentIndex] item.content.post = server.posts[currentIndex]
content.flickableItem.contentY = 0 //content.flickableItem.contentY = 0
previousPost = item.content.post previousPost = item.content.post
} }

View file

@ -4,6 +4,7 @@
#include <QMetaType> #include <QMetaType>
#include <QtQml> #include <QtQml>
#include <QIcon> #include <QIcon>
#include <QtWebEngine/qtwebengineglobal.h>
#include "tinytinyrsslogin.h" #include "tinytinyrsslogin.h"
#include "tinytinyrss.h" #include "tinytinyrss.h"
@ -16,6 +17,8 @@ int main(int argc, char *argv[])
app.setOrganizationDomain("jeena.net"); app.setOrganizationDomain("jeena.net");
app.setApplicationName("FeedTheMonkey"); app.setApplicationName("FeedTheMonkey");
QtWebEngine::initialize();
qmlRegisterType<TinyTinyRSSLogin>("TTRSS", 1, 0, "ServerLogin"); qmlRegisterType<TinyTinyRSSLogin>("TTRSS", 1, 0, "ServerLogin");
qmlRegisterType<TinyTinyRSS>("TTRSS", 1, 0, "Server"); qmlRegisterType<TinyTinyRSS>("TTRSS", 1, 0, "Server");
qmlRegisterType<Post>("TTRSS", 1, 0, "Post"); qmlRegisterType<Post>("TTRSS", 1, 0, "Post");

View file

@ -45,7 +45,6 @@ void Post::setRead(bool r)
void Post::setDontChangeRead(bool r) void Post::setDontChangeRead(bool r)
{ {
qDebug() << "setDontChangeRead " << r << " " << mDontChangeRead;
if(mDontChangeRead == r) return; if(mDontChangeRead == r) return;
mDontChangeRead = r; mDontChangeRead = r;