Skip to content

Commit

Permalink
Merge branch 'webengine'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeena committed Oct 13, 2015
2 parents edc8eac + c6c41c7 commit 342b1d6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion FeedTheMonkey.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TARGET = feedthemonkey

TEMPLATE = app
QT += qml quick
QT += qml quick webenginewidgets
CONFIG += c++11

SOURCES += \
Expand Down
4 changes: 2 additions & 2 deletions ports/arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

pkgname=feedthemonkey
_name=FeedTheMonkey
pkgver=2.0.0
pkgver=2.1.0
pkgrel=1
pkgdesc="Desktop client for the TinyTinyRSS reader"
arch=('i686' 'x86_64')
url="http://jabs.nu/feedthemonkey"
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")
md5sums=('SKIP')

Expand Down
39 changes: 16 additions & 23 deletions qml/Content.qml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import QtWebKit 3.0
import QtWebKit.experimental 1.0
import QtWebEngine 1.0
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.3
import QtQuick.Controls 1.3
import TTRSS 1.0

ScrollView {
Item {
id: content
property Post post
property ApplicationWindow app
Expand All @@ -18,23 +17,19 @@ ScrollView {
Layout.minimumWidth: 400
onTextFontSizeChanged: webView.setDefaults()

style: ScrollViewStyle {
transientScrollBars: true
}

function scrollDown(jump) {
if(!jump) {
webView.experimental.evaluateJavaScript("window.scrollTo(0, document.body.scrollHeight - " + height + ");")
webView.runJavaScript("window.scrollTo(0, document.body.scrollHeight - " + height + ");")
} else {
webView.experimental.evaluateJavaScript("window.scrollBy(0, " + jump + ");")
webView.runJavaScript("window.scrollBy(0, " + jump + ");")
}
}

function scrollUp(jump) {
if(!jump) {
webView.experimental.evaluateJavaScript("window.scrollTo(0, 0);")
webView.runJavaScript("window.scrollTo(0, 0);")
} else {
webView.experimental.evaluateJavaScript("window.scrollBy(0, -" + jump + ");")
webView.runJavaScript("window.scrollBy(0, -" + jump + ");")
}
}

Expand All @@ -44,41 +39,39 @@ ScrollView {

Label { id: fontLabel }

WebView {
WebEngineView {
id: webView
anchors.fill: parent
url: "../html/content.html"

// Enable communication between QML and WebKit
experimental.preferences.navigatorQtObjectEnabled: true;

property Post post: content.post

function setPost() {
if(post) {
experimental.evaluateJavaScript("setArticle(" + post.jsonString + ")")
runJavaScript("setArticle(" + post.jsonString + ")")
} else {
experimental.evaluateJavaScript("setArticle('logout')")
runJavaScript("setArticle('logout')")
}
}

function setDefaults() {
// font name needs to be enclosed in single quotes
experimental.evaluateJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'\";");
experimental.evaluateJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';");
runJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'\";");
runJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';");
}


onNavigationRequested: {
if (request.navigationType != WebView.LinkClickedNavigation) {
request.action = WebView.AcceptRequest;
if (request.navigationType != WebEngineView.LinkClickedNavigation) {
request.action = WebEngineView.AcceptRequest;
} else {
request.action = WebView.IgnoreRequest;
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.url);
}
}

onLoadingChanged: {
if(loadRequest.status === WebView.LoadSucceededStatus) {
if(!loading) {
setPost()
setDefaults()
}
Expand Down
2 changes: 1 addition & 1 deletion qml/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ScrollView {
}

item.content.post = server.posts[currentIndex]
content.flickableItem.contentY = 0
//content.flickableItem.contentY = 0

previousPost = item.content.post
}
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QMetaType>
#include <QtQml>
#include <QIcon>
#include <QtWebEngine/qtwebengineglobal.h>

#include "tinytinyrsslogin.h"
#include "tinytinyrss.h"
Expand All @@ -16,6 +17,8 @@ int main(int argc, char *argv[])
app.setOrganizationDomain("jeena.net");
app.setApplicationName("FeedTheMonkey");

QtWebEngine::initialize();

qmlRegisterType<TinyTinyRSSLogin>("TTRSS", 1, 0, "ServerLogin");
qmlRegisterType<TinyTinyRSS>("TTRSS", 1, 0, "Server");
qmlRegisterType<Post>("TTRSS", 1, 0, "Post");
Expand Down
1 change: 0 additions & 1 deletion src/post.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void Post::setRead(bool r)

void Post::setDontChangeRead(bool r)
{
qDebug() << "setDontChangeRead " << r << " " << mDontChangeRead;
if(mDontChangeRead == r) return;

mDontChangeRead = r;
Expand Down

0 comments on commit 342b1d6

Please sign in to comment.