author | sl |
Mon, 02 Jun 2014 21:56:03 +0200 | |
changeset 28 | 8297924aa384 |
parent 14 | 9903a5edeb56 |
permissions | -rw-r--r-- |
sl@0 | 1 |
import QtQuick 2.2 |
sl@0 | 2 |
import QtQuick.Controls 1.2 |
sl@0 | 3 |
import QtQuick.Dialogs 1.1 |
sl@1 | 4 |
import QtQuick.Layouts 1.1 |
sl@1 | 5 |
import Qt.labs.settings 1.0 |
sl@0 | 6 |
|
sl@0 | 7 |
Item { |
sl@0 | 8 |
clip: true |
sl@14 | 9 |
// |
sl@1 | 10 |
Settings { |
sl@1 | 11 |
property alias font: textFontDemoLowerCase.font; |
sl@14 | 12 |
property alias checkBoxScalableFonts: checkBoxScalableFonts.checked |
sl@14 | 13 |
property alias checkBoxNonScalableFonts: checkBoxNonScalableFonts.checked |
sl@14 | 14 |
property alias checkBoxMonospacedFonts: checkBoxMonospacedFonts.checked |
sl@14 | 15 |
property alias checkBoxProportionalFonts: checkBoxProportionalFonts.checked |
sl@14 | 16 |
|
sl@1 | 17 |
} |
sl@1 | 18 |
|
sl@1 | 19 |
|
sl@0 | 20 |
// |
sl@0 | 21 |
FontDialog { |
sl@0 | 22 |
id: fontDialog |
sl@0 | 23 |
visible: false |
sl@0 | 24 |
modality: Qt.WindowModal |
sl@14 | 25 |
scalableFonts: checkBoxScalableFonts.checked |
sl@14 | 26 |
nonScalableFonts: checkBoxNonScalableFonts.checked |
sl@14 | 27 |
monospacedFonts: checkBoxMonospacedFonts.checked |
sl@14 | 28 |
proportionalFonts: checkBoxProportionalFonts.checked |
sl@0 | 29 |
title: qsTr("Choose a font") |
sl@1 | 30 |
font: textFontDemoLowerCase.font |
sl@1 | 31 |
currentFont: textFontDemoLowerCase.font |
sl@14 | 32 |
//onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) } |
sl@14 | 33 |
//onFontChanged: { console.log("FontChanged: " + font) } |
sl@1 | 34 |
onAccepted: { |
sl@14 | 35 |
//console.log("Accepted: " + font); |
sl@1 | 36 |
textFontDemoLowerCase.font = currentFont; |
sl@15 | 37 |
display.clear(); |
sl@5 | 38 |
display.font = currentFont; |
sl@15 | 39 |
display.swapBuffers(); |
sl@1 | 40 |
//textFontDemoUpperCase.font = currentFont; |
sl@1 | 41 |
//textFontDemoDigits.font = currentFont; |
sl@1 | 42 |
} |
sl@14 | 43 |
//onRejected: { console.log("Rejected") } |
sl@0 | 44 |
} |
sl@0 | 45 |
// |
sl@1 | 46 |
ColumnLayout { |
sl@0 | 47 |
anchors.fill: parent |
sl@1 | 48 |
anchors.margins: 8 |
sl@1 | 49 |
spacing: 8 |
sl@0 | 50 |
|
sl@13 | 51 |
Label { |
sl@0 | 52 |
id: fontLabel |
sl@1 | 53 |
text: "Current font: <b>" + textFontDemoLowerCase.font.family + " - " + textFontDemoLowerCase.font.pointSize +"</b>" |
sl@0 | 54 |
MouseArea { |
sl@0 | 55 |
anchors.fill: parent |
sl@0 | 56 |
onClicked: fontDialog.open() |
sl@0 | 57 |
} |
sl@0 | 58 |
} |
sl@0 | 59 |
|
sl@1 | 60 |
ColumnLayout { |
sl@1 | 61 |
anchors.margins: 0 |
sl@1 | 62 |
spacing: 0 |
sl@1 | 63 |
|
sl@13 | 64 |
Label { |
sl@1 | 65 |
id: textFontDemoLowerCase |
sl@1 | 66 |
anchors.margins: 0 |
sl@1 | 67 |
text: "abcdefghijklmnopqrstyvwxyz" |
sl@1 | 68 |
font: Qt.font({ family: "Arial", pointSize: 16, weight: Font.Normal }) |
sl@1 | 69 |
} |
sl@1 | 70 |
|
sl@13 | 71 |
Label { |
sl@1 | 72 |
id: textFontDemoUpperCase |
sl@1 | 73 |
anchors.margins: 0 |
sl@1 | 74 |
text: "ABCDEFGHIJKLMNOPQRSTYVWXYZ" |
sl@1 | 75 |
font: textFontDemoLowerCase.font |
sl@1 | 76 |
} |
sl@1 | 77 |
|
sl@13 | 78 |
Label { |
sl@1 | 79 |
id: textFontDemoDigits |
sl@1 | 80 |
anchors.margins: 0 |
sl@1 | 81 |
text: "0123456789" |
sl@1 | 82 |
font: textFontDemoLowerCase.font |
sl@1 | 83 |
} |
sl@0 | 84 |
} |
sl@0 | 85 |
|
sl@1 | 86 |
//Font selection options |
sl@1 | 87 |
GridLayout { |
sl@1 | 88 |
anchors.margins: 8 |
sl@1 | 89 |
columns: 2 |
sl@1 | 90 |
columnSpacing: 8 |
sl@1 | 91 |
|
sl@1 | 92 |
CheckBox { |
sl@14 | 93 |
id: checkBoxScalableFonts |
sl@1 | 94 |
text: "Scalable fonts" |
sl@14 | 95 |
checked: true |
sl@14 | 96 |
//Binding on checked { value: fontDialog.scalableFonts } |
sl@1 | 97 |
} |
sl@1 | 98 |
CheckBox { |
sl@14 | 99 |
id: checkBoxNonScalableFonts |
sl@1 | 100 |
text: "Non scalable fonts" |
sl@14 | 101 |
checked: true |
sl@14 | 102 |
//Binding on checked { value: fontDialog.nonScalableFonts } |
sl@1 | 103 |
} |
sl@1 | 104 |
CheckBox { |
sl@14 | 105 |
id: checkBoxMonospacedFonts |
sl@1 | 106 |
text: "Monospaced fonts" |
sl@14 | 107 |
checked: true |
sl@14 | 108 |
//Binding on checked { value: fontDialog.monospacedFonts } |
sl@1 | 109 |
} |
sl@1 | 110 |
CheckBox { |
sl@14 | 111 |
id: checkBoxProportionalFonts |
sl@1 | 112 |
text: "Proportional fonts" |
sl@14 | 113 |
checked: true |
sl@14 | 114 |
//Binding on checked { value: fontDialog.proportionalFonts } |
sl@1 | 115 |
} |
sl@0 | 116 |
} |
sl@0 | 117 |
|
sl@0 | 118 |
|
sl@0 | 119 |
|
sl@0 | 120 |
Button { |
sl@1 | 121 |
text: qsTr("Change font") |
sl@14 | 122 |
onClicked: { |
sl@14 | 123 |
//We had to do this double magic cause otherwise our font list |
sl@14 | 124 |
//would not reflect our options. |
sl@14 | 125 |
fontDialog.setVisible(true); |
sl@14 | 126 |
fontDialog.open(); |
sl@14 | 127 |
} |
sl@0 | 128 |
} |
sl@1 | 129 |
} //ColumnLayout |
sl@1 | 130 |
} //Item |