fixed font resizing
This commit is contained in:
parent
dd17ff43b2
commit
40aec194bd
7 changed files with 101 additions and 69 deletions
|
@ -12,11 +12,11 @@ ScrollView {
|
|||
property Post post
|
||||
property ApplicationWindow app
|
||||
|
||||
property int headLinefontSize: 23
|
||||
property int textfontSize: 14
|
||||
property int textFontSize: 14
|
||||
property int scrollJump: 48
|
||||
property int pageJump: parent.height
|
||||
Layout.minimumWidth: 400
|
||||
onTextFontSizeChanged: webView.setDefaults()
|
||||
|
||||
style: ScrollViewStyle {
|
||||
transientScrollBars: true
|
||||
|
@ -58,7 +58,7 @@ ScrollView {
|
|||
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 = '" + fontLabel.font.pointSize + "pt';");
|
||||
experimental.evaluateJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3
|
||||
|
||||
Component {
|
||||
Item {
|
||||
property int headLinefontSize: 14
|
||||
Item {
|
||||
property int textFontSize: 14
|
||||
property int smallfontSize: 11
|
||||
|
||||
Component.onCompleted: fixFontSize()
|
||||
onTextFontSizeChanged: fixFontSize()
|
||||
|
||||
function fixFontSize() {
|
||||
smallfontSize = textFontSize * 0.8
|
||||
}
|
||||
|
||||
id: item
|
||||
height: column.height + 20
|
||||
width: parent.parent.parent.width
|
||||
|
@ -48,7 +54,7 @@ Component {
|
|||
Label {
|
||||
text: title
|
||||
color: read ? "gray" : "black"
|
||||
font.pointSize: headLinefontSize
|
||||
font.pointSize: textFontSize
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
renderType: Text.NativeRendering
|
||||
|
@ -80,5 +86,4 @@ Component {
|
|||
parent.parent.parent.currentIndex = index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ ScrollView {
|
|||
property Server server
|
||||
property Content content
|
||||
property Post previousPost
|
||||
property int textFontSize: 14
|
||||
|
||||
style: ScrollViewStyle {
|
||||
transientScrollBars: true
|
||||
|
@ -35,7 +36,11 @@ ScrollView {
|
|||
spacing: 1
|
||||
model: item.server.posts
|
||||
|
||||
delegate: PostListItem {}
|
||||
delegate: Component {
|
||||
PostListItem {
|
||||
textFontSize: item.textFontSize
|
||||
}
|
||||
}
|
||||
|
||||
highlightFollowsCurrentItem: false
|
||||
highlight: Component {
|
||||
|
|
|
@ -84,17 +84,20 @@ MenuBar {
|
|||
MenuItem {
|
||||
text: qsTr("Zoom In")
|
||||
shortcut: "Ctrl++"
|
||||
enabled: false
|
||||
enabled: true
|
||||
onTriggered: app.zoomIn()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Zoom Out")
|
||||
shortcut: "Ctrl+-"
|
||||
enabled: false
|
||||
enabled: true
|
||||
onTriggered: app.zoomOut()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Reset")
|
||||
shortcut: "Ctrl+0"
|
||||
enabled: false
|
||||
enabled: true
|
||||
onTriggered: app.zoomReset()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ body {
|
|||
|
||||
h1 {
|
||||
font-weight: lighter;
|
||||
font-size: 1.4em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
|
|
@ -45,5 +45,5 @@ function setArticle(article) {
|
|||
|
||||
function setFont(font, size) {
|
||||
document.body.style.fontFamily = font;
|
||||
//document.body.style.fontSize = size + "pt";
|
||||
document.body.style.fontSize = size + "pt";
|
||||
}
|
||||
|
|
18
main.qml
18
main.qml
|
@ -19,6 +19,9 @@ ApplicationWindow {
|
|||
property Sidebar sidebar: sidebar
|
||||
property Content content: content
|
||||
|
||||
property int defaultTextFontSize: 13
|
||||
property int textFontSize: defaultTextFontSize
|
||||
|
||||
Settings {
|
||||
category: "window"
|
||||
property alias x: app.x
|
||||
|
@ -26,6 +29,7 @@ ApplicationWindow {
|
|||
property alias width: app.width
|
||||
property alias height: app.height
|
||||
property alias sidebarWidth: sidebar.width
|
||||
//property alias textFontSize: app.textFontSize
|
||||
}
|
||||
|
||||
property TheMenuBar menu: TheMenuBar {
|
||||
|
@ -41,6 +45,18 @@ ApplicationWindow {
|
|||
server.initialize(serverLogin.serverUrl, serverLogin.sessionId);
|
||||
}
|
||||
|
||||
function zoomIn() {
|
||||
textFontSize *= 1.2
|
||||
}
|
||||
|
||||
function zoomOut() {
|
||||
textFontSize *= 0.8
|
||||
}
|
||||
|
||||
function zoomReset() {
|
||||
textFontSize = defaultTextFontSize
|
||||
}
|
||||
|
||||
function keyPressed(event) {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Right:
|
||||
|
@ -94,6 +110,7 @@ ApplicationWindow {
|
|||
|
||||
Layout.minimumWidth: 200
|
||||
implicitWidth: 300
|
||||
textFontSize: app.textFontSize
|
||||
}
|
||||
|
||||
Content {
|
||||
|
@ -102,6 +119,7 @@ ApplicationWindow {
|
|||
|
||||
Layout.minimumWidth: 200
|
||||
implicitWidth: 624
|
||||
textFontSize: app.textFontSize
|
||||
}
|
||||
|
||||
Keys.onPressed: keyPressed(event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue