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 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';");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
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
|
||||||
|
|
||||||
|
Component.onCompleted: fixFontSize()
|
||||||
|
onTextFontSizeChanged: fixFontSize()
|
||||||
|
|
||||||
|
function fixFontSize() {
|
||||||
|
smallfontSize = textFontSize * 0.8
|
||||||
|
}
|
||||||
|
|
||||||
id: item
|
id: item
|
||||||
height: column.height + 20
|
height: column.height + 20
|
||||||
width: parent.parent.parent.width
|
width: parent.parent.parent.width
|
||||||
|
@ -48,7 +54,7 @@ Component {
|
||||||
Label {
|
Label {
|
||||||
text: title
|
text: title
|
||||||
color: read ? "gray" : "black"
|
color: read ? "gray" : "black"
|
||||||
font.pointSize: headLinefontSize
|
font.pointSize: textFontSize
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
|
@ -80,5 +86,4 @@ Component {
|
||||||
parent.parent.parent.currentIndex = index
|
parent.parent.parent.currentIndex = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
18
main.qml
18
main.qml
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue