Working around our font dialog option listing issues.
authorsl
Wed, 28 May 2014 21:31:03 +0200
changeset 149903a5edeb56
parent 13 40da62e57d85
child 15 737f8bb110be
Working around our font dialog option listing issues.
Font dialog options are now persisted.
Fixing issue with italic font being cut by using proper string width from boundigRect.
DisplayTab.qml
FontsTab.qml
MiniDisplay/minidisplay.cpp
     1.1 --- a/DisplayTab.qml	Wed May 28 20:14:23 2014 +0200
     1.2 +++ b/DisplayTab.qml	Wed May 28 21:31:03 2014 +0200
     1.3 @@ -7,8 +7,8 @@
     1.4  
     1.5  
     1.6  Item {
     1.7 -    width: 100
     1.8 -    height: 62
     1.9 +    //width: 100
    1.10 +    //height: 62
    1.11      //SystemPalette { id: palette }
    1.12      clip: true
    1.13      //
     2.1 --- a/FontsTab.qml	Wed May 28 20:14:23 2014 +0200
     2.2 +++ b/FontsTab.qml	Wed May 28 21:31:03 2014 +0200
     2.3 @@ -5,15 +5,15 @@
     2.4  import Qt.labs.settings 1.0
     2.5  
     2.6  Item {
     2.7 -    width: 640
     2.8 -    height: 480
     2.9 -    //SystemPalette { id: palette }
    2.10      clip: true
    2.11 -
    2.12 -
    2.13 -
    2.14 +    //
    2.15      Settings {
    2.16          property alias font: textFontDemoLowerCase.font;
    2.17 +        property alias checkBoxScalableFonts: checkBoxScalableFonts.checked
    2.18 +        property alias checkBoxNonScalableFonts: checkBoxNonScalableFonts.checked
    2.19 +        property alias checkBoxMonospacedFonts: checkBoxMonospacedFonts.checked
    2.20 +        property alias checkBoxProportionalFonts: checkBoxProportionalFonts.checked
    2.21 +
    2.22      }
    2.23  
    2.24  
    2.25 @@ -22,23 +22,23 @@
    2.26          id: fontDialog
    2.27          visible: false
    2.28          modality: Qt.WindowModal
    2.29 -        scalableFonts: fontDialogScalableFonts.checked
    2.30 -        nonScalableFonts: fontDialogNonScalableFonts.checked
    2.31 -        monospacedFonts: fontDialogMonospacedFonts.checked
    2.32 -        proportionalFonts: fontDialogProportionalFonts.checked
    2.33 +        scalableFonts: checkBoxScalableFonts.checked
    2.34 +        nonScalableFonts: checkBoxNonScalableFonts.checked
    2.35 +        monospacedFonts: checkBoxMonospacedFonts.checked
    2.36 +        proportionalFonts: checkBoxProportionalFonts.checked
    2.37          title: qsTr("Choose a font")
    2.38          font: textFontDemoLowerCase.font
    2.39          currentFont: textFontDemoLowerCase.font
    2.40 -        onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
    2.41 -        onFontChanged: { console.log("FontChanged: " + font) }
    2.42 +        //onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
    2.43 +        //onFontChanged: { console.log("FontChanged: " + font) }
    2.44          onAccepted: {
    2.45 -            console.log("Accepted: " + font);
    2.46 +            //console.log("Accepted: " + font);
    2.47              textFontDemoLowerCase.font = currentFont;
    2.48              display.font = currentFont;
    2.49              //textFontDemoUpperCase.font = currentFont;
    2.50              //textFontDemoDigits.font = currentFont;
    2.51          }
    2.52 -        onRejected: { console.log("Rejected") }
    2.53 +        //onRejected: { console.log("Rejected") }
    2.54      }
    2.55      //
    2.56      ColumnLayout {
    2.57 @@ -88,24 +88,28 @@
    2.58              columnSpacing: 8
    2.59  
    2.60              CheckBox {
    2.61 -                id: fontDialogScalableFonts
    2.62 +                id: checkBoxScalableFonts
    2.63                  text: "Scalable fonts"
    2.64 -                Binding on checked { value: fontDialog.scalableFonts }
    2.65 +                checked: true
    2.66 +                //Binding on checked { value: fontDialog.scalableFonts }
    2.67              }
    2.68              CheckBox {
    2.69 -                id: fontDialogNonScalableFonts
    2.70 +                id: checkBoxNonScalableFonts
    2.71                  text: "Non scalable fonts"
    2.72 -                Binding on checked { value: fontDialog.nonScalableFonts }
    2.73 +                checked: true
    2.74 +                //Binding on checked { value: fontDialog.nonScalableFonts }
    2.75              }
    2.76              CheckBox {
    2.77 -                id: fontDialogMonospacedFonts
    2.78 +                id: checkBoxMonospacedFonts
    2.79                  text: "Monospaced fonts"
    2.80 -                Binding on checked { value: fontDialog.monospacedFonts }
    2.81 +                checked: true
    2.82 +                //Binding on checked { value: fontDialog.monospacedFonts }
    2.83              }
    2.84              CheckBox {
    2.85 -                id: fontDialogProportionalFonts
    2.86 +                id: checkBoxProportionalFonts
    2.87                  text: "Proportional fonts"
    2.88 -                Binding on checked { value: fontDialog.proportionalFonts }
    2.89 +                checked: true
    2.90 +                //Binding on checked { value: fontDialog.proportionalFonts }
    2.91              }
    2.92          }
    2.93  
    2.94 @@ -113,7 +117,12 @@
    2.95  
    2.96          Button {
    2.97              text: qsTr("Change font")
    2.98 -            onClicked: fontDialog.open()
    2.99 +            onClicked: {
   2.100 +                //We had to do this double magic cause otherwise our font list
   2.101 +                //would not reflect our options.
   2.102 +                fontDialog.setVisible(true);
   2.103 +                fontDialog.open();
   2.104 +            }
   2.105          }
   2.106      } //ColumnLayout
   2.107  } //Item
     3.1 --- a/MiniDisplay/minidisplay.cpp	Wed May 28 20:14:23 2014 +0200
     3.2 +++ b/MiniDisplay/minidisplay.cpp	Wed May 28 21:31:03 2014 +0200
     3.3 @@ -122,8 +122,9 @@
     3.4      iFont.setStyleStrategy(QFont::NoAntialias);
     3.5      QString strDemo="0123456789ABCDEF";
     3.6      QFontMetrics metrics(iFont);
     3.7 -    int w=metrics.width(strDemo);
     3.8 +    int w=metrics.boundingRect(strDemo).width();
     3.9      int h=metrics.height();
    3.10 +    //int h=metrics.boundingRect(strDemo).height();
    3.11      QSize size(w,h);
    3.12      //Rendering in mono is quite broken we need RGB32
    3.13      QImage image(size,QImage::Format_RGB32);
    3.14 @@ -131,7 +132,6 @@
    3.15      //Draw some text into our image
    3.16      {
    3.17          QPainter painter(&image);
    3.18 -        //painter.begin(&image);
    3.19          painter.setPen(0xFF000000);
    3.20          painter.setFont(iFont);
    3.21          painter.drawText(0,metrics.ascent(),strDemo);