fixed font resizing

This commit is contained in:
Jeena 2015-02-17 19:51:59 +01:00
parent dd17ff43b2
commit 40aec194bd
7 changed files with 101 additions and 69 deletions

View file

@ -12,11 +12,11 @@ ScrollView {
property Post post property Post post
property ApplicationWindow app property ApplicationWindow app
property int headLinefontSize: 23 property int textFontSize: 14
property int textfontSize: 14
property int scrollJump: 48 property int scrollJump: 48
property int pageJump: parent.height property int pageJump: parent.height
Layout.minimumWidth: 400 Layout.minimumWidth: 400
onTextFontSizeChanged: webView.setDefaults()
style: ScrollViewStyle { style: ScrollViewStyle {
transientScrollBars: true transientScrollBars: true
@ -58,7 +58,7 @@ ScrollView {
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 + "'\";"); experimental.evaluateJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'\";");
experimental.evaluateJavaScript("document.body.style.fontSize = '" + fontLabel.font.pointSize + "pt';"); experimental.evaluateJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';");
} }

View file

@ -1,84 +1,89 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.3 import QtQuick.Controls 1.3
Component { Item {
Item { property int textFontSize: 14
property int headLinefontSize: 14 property int smallfontSize: 11
property int smallfontSize: 11
id: item Component.onCompleted: fixFontSize()
height: column.height + 20 onTextFontSizeChanged: fixFontSize()
width: parent.parent.parent.width
function fixFontSize() {
smallfontSize = textFontSize * 0.8
}
id: item
height: column.height + 20
width: parent.parent.parent.width
Rectangle {
anchors.fill: parent
color: "transparent"
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: 15
anchors.rightMargin: 15
anchors.topMargin: 10
anchors.bottomMargin: 10
color: "transparent" color: "transparent"
Rectangle { Column {
anchors.fill: parent id: column
anchors.leftMargin: 15 width: parent.width
anchors.rightMargin: 15
anchors.topMargin: 10
anchors.bottomMargin: 10
color: "transparent"
Column { Row {
id: column spacing: 10
width: parent.width
Row {
spacing: 10
Label {
text: feedTitle
font.pointSize: smallfontSize
textFormat: Text.PlainText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
}
Label {
text: date.toLocaleString(Qt.locale(), Locale.ShortFormat)
font.pointSize: smallfontSize
textFormat: Text.PlainText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
}
}
Label { Label {
text: title text: feedTitle
color: read ? "gray" : "black"
font.pointSize: headLinefontSize
textFormat: Text.RichText
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
width: parent.width
}
Label {
text: excerpt
font.pointSize: smallfontSize font.pointSize: smallfontSize
textFormat: Text.RichText textFormat: Text.PlainText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
}
Label {
text: date.toLocaleString(Qt.locale(), Locale.ShortFormat)
font.pointSize: smallfontSize
textFormat: Text.PlainText
color: "gray" color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering renderType: Text.NativeRendering
width: parent.width
} }
} }
} Label {
text: title
Rectangle { color: read ? "gray" : "black"
anchors.top: parent.bottom font.pointSize: textFontSize
width: parent.width textFormat: Text.RichText
height: 1 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: "lightgray" renderType: Text.NativeRendering
width: parent.width
}
Label {
text: excerpt
font.pointSize: smallfontSize
textFormat: Text.RichText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
width: parent.width
}
} }
} }
MouseArea { Rectangle {
anchors.fill: parent anchors.top: parent.bottom
onClicked: { width: parent.width
parent.parent.parent.currentIndex = index height: 1
} color: "lightgray"
}
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.parent.parent.currentIndex = index
} }
} }
} }

View file

@ -10,6 +10,7 @@ ScrollView {
property Server server property Server server
property Content content property Content content
property Post previousPost property Post previousPost
property int textFontSize: 14
style: ScrollViewStyle { style: ScrollViewStyle {
transientScrollBars: true transientScrollBars: true
@ -35,7 +36,11 @@ ScrollView {
spacing: 1 spacing: 1
model: item.server.posts model: item.server.posts
delegate: PostListItem {} delegate: Component {
PostListItem {
textFontSize: item.textFontSize
}
}
highlightFollowsCurrentItem: false highlightFollowsCurrentItem: false
highlight: Component { highlight: Component {

View file

@ -84,17 +84,20 @@ MenuBar {
MenuItem { MenuItem {
text: qsTr("Zoom In") text: qsTr("Zoom In")
shortcut: "Ctrl++" shortcut: "Ctrl++"
enabled: false enabled: true
onTriggered: app.zoomIn()
} }
MenuItem { MenuItem {
text: qsTr("Zoom Out") text: qsTr("Zoom Out")
shortcut: "Ctrl+-" shortcut: "Ctrl+-"
enabled: false enabled: true
onTriggered: app.zoomOut()
} }
MenuItem { MenuItem {
text: qsTr("Reset") text: qsTr("Reset")
shortcut: "Ctrl+0" shortcut: "Ctrl+0"
enabled: false enabled: true
onTriggered: app.zoomReset()
} }
} }

View file

@ -8,6 +8,7 @@ body {
h1 { h1 {
font-weight: lighter; font-weight: lighter;
font-size: 1.4em;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }

View file

@ -45,5 +45,5 @@ function setArticle(article) {
function setFont(font, size) { function setFont(font, size) {
document.body.style.fontFamily = font; document.body.style.fontFamily = font;
//document.body.style.fontSize = size + "pt"; document.body.style.fontSize = size + "pt";
} }

View file

@ -19,6 +19,9 @@ ApplicationWindow {
property Sidebar sidebar: sidebar property Sidebar sidebar: sidebar
property Content content: content property Content content: content
property int defaultTextFontSize: 13
property int textFontSize: defaultTextFontSize
Settings { Settings {
category: "window" category: "window"
property alias x: app.x property alias x: app.x
@ -26,6 +29,7 @@ ApplicationWindow {
property alias width: app.width property alias width: app.width
property alias height: app.height property alias height: app.height
property alias sidebarWidth: sidebar.width property alias sidebarWidth: sidebar.width
//property alias textFontSize: app.textFontSize
} }
property TheMenuBar menu: TheMenuBar { property TheMenuBar menu: TheMenuBar {
@ -41,6 +45,18 @@ ApplicationWindow {
server.initialize(serverLogin.serverUrl, serverLogin.sessionId); server.initialize(serverLogin.serverUrl, serverLogin.sessionId);
} }
function zoomIn() {
textFontSize *= 1.2
}
function zoomOut() {
textFontSize *= 0.8
}
function zoomReset() {
textFontSize = defaultTextFontSize
}
function keyPressed(event) { function keyPressed(event) {
switch (event.key) { switch (event.key) {
case Qt.Key_Right: case Qt.Key_Right:
@ -94,6 +110,7 @@ ApplicationWindow {
Layout.minimumWidth: 200 Layout.minimumWidth: 200
implicitWidth: 300 implicitWidth: 300
textFontSize: app.textFontSize
} }
Content { Content {
@ -102,6 +119,7 @@ ApplicationWindow {
Layout.minimumWidth: 200 Layout.minimumWidth: 200
implicitWidth: 624 implicitWidth: 624
textFontSize: app.textFontSize
} }
Keys.onPressed: keyPressed(event) Keys.onPressed: keyPressed(event)