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