FontsTab.qml
author sl
Tue, 27 May 2014 17:14:22 +0200
changeset 2 780ee91f4ffb
parent 0 c0e13d2503b9
child 5 62a1d3631dcb
permissions -rw-r--r--
Creating a quick item for our MiniDisplay.
     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             //textFontDemoUpperCase.font = currentFont;
    38             //textFontDemoDigits.font = currentFont;
    39         }
    40         onRejected: { console.log("Rejected") }
    41     }
    42     //
    43     ColumnLayout {
    44         anchors.fill: parent
    45         anchors.margins: 8
    46         spacing: 8
    47 
    48         Text {
    49             id: fontLabel
    50             text: "Current font: <b>" + textFontDemoLowerCase.font.family + " - " + textFontDemoLowerCase.font.pointSize +"</b>"
    51             MouseArea {
    52                 anchors.fill: parent
    53                 onClicked: fontDialog.open()
    54             }
    55         }
    56 
    57         ColumnLayout {
    58             anchors.margins: 0
    59             spacing: 0
    60 
    61             Text {
    62                 id: textFontDemoLowerCase
    63                 anchors.margins: 0
    64                 text: "abcdefghijklmnopqrstyvwxyz"
    65                 font: Qt.font({ family: "Arial", pointSize: 16, weight: Font.Normal })
    66             }
    67 
    68             Text {
    69                 id: textFontDemoUpperCase
    70                 anchors.margins: 0
    71                 text: "ABCDEFGHIJKLMNOPQRSTYVWXYZ"
    72                 font: textFontDemoLowerCase.font
    73             }
    74 
    75             Text {
    76                 id: textFontDemoDigits
    77                 anchors.margins: 0
    78                 text: "0123456789"
    79                 font: textFontDemoLowerCase.font
    80             }
    81         }
    82 
    83         //Font selection options
    84         GridLayout {
    85             anchors.margins: 8
    86             columns: 2
    87             columnSpacing: 8
    88 
    89             CheckBox {
    90                 id: fontDialogScalableFonts
    91                 text: "Scalable fonts"
    92                 Binding on checked { value: fontDialog.scalableFonts }
    93             }
    94             CheckBox {
    95                 id: fontDialogNonScalableFonts
    96                 text: "Non scalable fonts"
    97                 Binding on checked { value: fontDialog.nonScalableFonts }
    98             }
    99             CheckBox {
   100                 id: fontDialogMonospacedFonts
   101                 text: "Monospaced fonts"
   102                 Binding on checked { value: fontDialog.monospacedFonts }
   103             }
   104             CheckBox {
   105                 id: fontDialogProportionalFonts
   106                 text: "Proportional fonts"
   107                 Binding on checked { value: fontDialog.proportionalFonts }
   108             }
   109         }
   110 
   111 
   112 
   113         Button {
   114             text: qsTr("Change font")
   115             onClicked: fontDialog.open()
   116         }
   117     } //ColumnLayout
   118 } //Item