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