FontsTab.qml
author sl
Wed, 28 May 2014 08:06:27 +0200
changeset 6 b1b049e28772
parent 1 bc046f5187fd
child 13 40da62e57d85
permissions -rw-r--r--
Basic font rendering now working nicely.
     1 import QtQuick 2.2
     2 import QtQuick.Controls 1.2
     3 import QtQuick.Dialogs 1.1
     4 import QtQuick.Layouts 1.1
     5 import Qt.labs.settings 1.0
     6 
     7 Item {
     8     width: 640
     9     height: 480
    10     //SystemPalette { id: palette }
    11     clip: true
    12 
    13 
    14 
    15     Settings {
    16         property alias font: textFontDemoLowerCase.font;
    17     }
    18 
    19 
    20     //
    21     FontDialog {
    22         id: fontDialog
    23         visible: false
    24         modality: Qt.WindowModal
    25         scalableFonts: fontDialogScalableFonts.checked
    26         nonScalableFonts: fontDialogNonScalableFonts.checked
    27         monospacedFonts: fontDialogMonospacedFonts.checked
    28         proportionalFonts: fontDialogProportionalFonts.checked
    29         title: qsTr("Choose a font")
    30         font: textFontDemoLowerCase.font
    31         currentFont: textFontDemoLowerCase.font
    32         onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
    33         onFontChanged: { console.log("FontChanged: " + font) }
    34         onAccepted: {
    35             console.log("Accepted: " + font);
    36             textFontDemoLowerCase.font = currentFont;
    37             display.font = currentFont;
    38             //textFontDemoUpperCase.font = currentFont;
    39             //textFontDemoDigits.font = currentFont;
    40         }
    41         onRejected: { console.log("Rejected") }
    42     }
    43     //
    44     ColumnLayout {
    45         anchors.fill: parent
    46         anchors.margins: 8
    47         spacing: 8
    48 
    49         Text {
    50             id: fontLabel
    51             text: "Current font: <b>" + textFontDemoLowerCase.font.family + " - " + textFontDemoLowerCase.font.pointSize +"</b>"
    52             MouseArea {
    53                 anchors.fill: parent
    54                 onClicked: fontDialog.open()
    55             }
    56         }
    57 
    58         ColumnLayout {
    59             anchors.margins: 0
    60             spacing: 0
    61 
    62             Text {
    63                 id: textFontDemoLowerCase
    64                 anchors.margins: 0
    65                 text: "abcdefghijklmnopqrstyvwxyz"
    66                 font: Qt.font({ family: "Arial", pointSize: 16, weight: Font.Normal })
    67             }
    68 
    69             Text {
    70                 id: textFontDemoUpperCase
    71                 anchors.margins: 0
    72                 text: "ABCDEFGHIJKLMNOPQRSTYVWXYZ"
    73                 font: textFontDemoLowerCase.font
    74             }
    75 
    76             Text {
    77                 id: textFontDemoDigits
    78                 anchors.margins: 0
    79                 text: "0123456789"
    80                 font: textFontDemoLowerCase.font
    81             }
    82         }
    83 
    84         //Font selection options
    85         GridLayout {
    86             anchors.margins: 8
    87             columns: 2
    88             columnSpacing: 8
    89 
    90             CheckBox {
    91                 id: fontDialogScalableFonts
    92                 text: "Scalable fonts"
    93                 Binding on checked { value: fontDialog.scalableFonts }
    94             }
    95             CheckBox {
    96                 id: fontDialogNonScalableFonts
    97                 text: "Non scalable fonts"
    98                 Binding on checked { value: fontDialog.nonScalableFonts }
    99             }
   100             CheckBox {
   101                 id: fontDialogMonospacedFonts
   102                 text: "Monospaced fonts"
   103                 Binding on checked { value: fontDialog.monospacedFonts }
   104             }
   105             CheckBox {
   106                 id: fontDialogProportionalFonts
   107                 text: "Proportional fonts"
   108                 Binding on checked { value: fontDialog.proportionalFonts }
   109             }
   110         }
   111 
   112 
   113 
   114         Button {
   115             text: qsTr("Change font")
   116             onClicked: fontDialog.open()
   117         }
   118     } //ColumnLayout
   119 } //Item