FontsTab.qml
changeset 1 bc046f5187fd
parent 0 c0e13d2503b9
child 5 62a1d3631dcb
     1.1 --- a/FontsTab.qml	Tue May 27 12:00:47 2014 +0200
     1.2 +++ b/FontsTab.qml	Tue May 27 13:08:12 2014 +0200
     1.3 @@ -1,6 +1,8 @@
     1.4  import QtQuick 2.2
     1.5  import QtQuick.Controls 1.2
     1.6  import QtQuick.Dialogs 1.1
     1.7 +import QtQuick.Layouts 1.1
     1.8 +import Qt.labs.settings 1.0
     1.9  
    1.10  Item {
    1.11      width: 640
    1.12 @@ -9,6 +11,12 @@
    1.13      clip: true
    1.14  
    1.15  
    1.16 +
    1.17 +    Settings {
    1.18 +        property alias font: textFontDemoLowerCase.font;
    1.19 +    }
    1.20 +
    1.21 +
    1.22      //
    1.23      FontDialog {
    1.24          id: fontDialog
    1.25 @@ -19,78 +27,92 @@
    1.26          monospacedFonts: fontDialogMonospacedFonts.checked
    1.27          proportionalFonts: fontDialogProportionalFonts.checked
    1.28          title: qsTr("Choose a font")
    1.29 -        font: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal })
    1.30 -        currentFont: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal })
    1.31 +        font: textFontDemoLowerCase.font
    1.32 +        currentFont: textFontDemoLowerCase.font
    1.33          onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
    1.34 -        onAccepted: { console.log("Accepted: " + font) }
    1.35 +        onFontChanged: { console.log("FontChanged: " + font) }
    1.36 +        onAccepted: {
    1.37 +            console.log("Accepted: " + font);
    1.38 +            textFontDemoLowerCase.font = currentFont;
    1.39 +            //textFontDemoUpperCase.font = currentFont;
    1.40 +            //textFontDemoDigits.font = currentFont;
    1.41 +        }
    1.42          onRejected: { console.log("Rejected") }
    1.43      }
    1.44      //
    1.45 -
    1.46 -    Flow {
    1.47 +    ColumnLayout {
    1.48          anchors.fill: parent
    1.49 -        anchors.margins: 12
    1.50 -        spacing: 10
    1.51 -
    1.52 -        CheckBox {
    1.53 -            id: fontDialogScalableFonts
    1.54 -            text: "Scalable fonts"
    1.55 -            Binding on checked { value: fontDialog.scalableFonts }
    1.56 -        }
    1.57 -        CheckBox {
    1.58 -            id: fontDialogNonScalableFonts
    1.59 -            text: "Non scalable fonts"
    1.60 -            Binding on checked { value: fontDialog.nonScalableFonts }
    1.61 -        }
    1.62 -        CheckBox {
    1.63 -            id: fontDialogMonospacedFonts
    1.64 -            text: "Monospaced fonts"
    1.65 -            Binding on checked { value: fontDialog.monospacedFonts }
    1.66 -        }
    1.67 -        CheckBox {
    1.68 -            id: fontDialogProportionalFonts
    1.69 -            text: "Proportional fonts"
    1.70 -            Binding on checked { value: fontDialog.proportionalFonts }
    1.71 -        }
    1.72 -
    1.73 -        Text {
    1.74 -            text: "Current font:"
    1.75 -        }
    1.76 +        anchors.margins: 8
    1.77 +        spacing: 8
    1.78  
    1.79          Text {
    1.80              id: fontLabel
    1.81 -            color: palette.windowText
    1.82 -            text: "<b>" + fontDialog.font.family + " - " + fontDialog.font.pointSize + "</b>"
    1.83 +            text: "Current font: <b>" + textFontDemoLowerCase.font.family + " - " + textFontDemoLowerCase.font.pointSize +"</b>"
    1.84              MouseArea {
    1.85                  anchors.fill: parent
    1.86                  onClicked: fontDialog.open()
    1.87              }
    1.88          }
    1.89  
    1.90 -        Text {
    1.91 -            id: textFontDemoLowerCase
    1.92 -            text: "abcdefghijklmnopqrstyvwxyz"
    1.93 -            font: fontDialog.font
    1.94 +        ColumnLayout {
    1.95 +            anchors.margins: 0
    1.96 +            spacing: 0
    1.97 +
    1.98 +            Text {
    1.99 +                id: textFontDemoLowerCase
   1.100 +                anchors.margins: 0
   1.101 +                text: "abcdefghijklmnopqrstyvwxyz"
   1.102 +                font: Qt.font({ family: "Arial", pointSize: 16, weight: Font.Normal })
   1.103 +            }
   1.104 +
   1.105 +            Text {
   1.106 +                id: textFontDemoUpperCase
   1.107 +                anchors.margins: 0
   1.108 +                text: "ABCDEFGHIJKLMNOPQRSTYVWXYZ"
   1.109 +                font: textFontDemoLowerCase.font
   1.110 +            }
   1.111 +
   1.112 +            Text {
   1.113 +                id: textFontDemoDigits
   1.114 +                anchors.margins: 0
   1.115 +                text: "0123456789"
   1.116 +                font: textFontDemoLowerCase.font
   1.117 +            }
   1.118          }
   1.119  
   1.120 -        Text {
   1.121 -            id: textFontDemoUpperCase
   1.122 -            text: "ABCDEFGHIJKLMNOPQRSTYVWXYZ"
   1.123 -            font: fontDialog.font
   1.124 +        //Font selection options
   1.125 +        GridLayout {
   1.126 +            anchors.margins: 8
   1.127 +            columns: 2
   1.128 +            columnSpacing: 8
   1.129 +
   1.130 +            CheckBox {
   1.131 +                id: fontDialogScalableFonts
   1.132 +                text: "Scalable fonts"
   1.133 +                Binding on checked { value: fontDialog.scalableFonts }
   1.134 +            }
   1.135 +            CheckBox {
   1.136 +                id: fontDialogNonScalableFonts
   1.137 +                text: "Non scalable fonts"
   1.138 +                Binding on checked { value: fontDialog.nonScalableFonts }
   1.139 +            }
   1.140 +            CheckBox {
   1.141 +                id: fontDialogMonospacedFonts
   1.142 +                text: "Monospaced fonts"
   1.143 +                Binding on checked { value: fontDialog.monospacedFonts }
   1.144 +            }
   1.145 +            CheckBox {
   1.146 +                id: fontDialogProportionalFonts
   1.147 +                text: "Proportional fonts"
   1.148 +                Binding on checked { value: fontDialog.proportionalFonts }
   1.149 +            }
   1.150          }
   1.151  
   1.152 -        Text {
   1.153 -            id: textFontDemoDigits
   1.154 -            text: "0123456789"
   1.155 -            font: fontDialog.font
   1.156 -        }
   1.157  
   1.158  
   1.159          Button {
   1.160 -            text: qsTr("Select Font")
   1.161 +            text: qsTr("Change font")
   1.162              onClicked: fontDialog.open()
   1.163          }
   1.164 -
   1.165 -
   1.166 -    }
   1.167 -}
   1.168 +    } //ColumnLayout
   1.169 +} //Item