# HG changeset patch # User sl # Date 1401305463 -7200 # Node ID 9903a5edeb5685968cc5bb14fae9db30bacc706a # Parent 40da62e57d85cabbbf3b0b89c27c48795276d54b 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. diff -r 40da62e57d85 -r 9903a5edeb56 DisplayTab.qml --- a/DisplayTab.qml Wed May 28 20:14:23 2014 +0200 +++ b/DisplayTab.qml Wed May 28 21:31:03 2014 +0200 @@ -7,8 +7,8 @@ Item { - width: 100 - height: 62 + //width: 100 + //height: 62 //SystemPalette { id: palette } clip: true // diff -r 40da62e57d85 -r 9903a5edeb56 FontsTab.qml --- a/FontsTab.qml Wed May 28 20:14:23 2014 +0200 +++ b/FontsTab.qml Wed May 28 21:31:03 2014 +0200 @@ -5,15 +5,15 @@ import Qt.labs.settings 1.0 Item { - width: 640 - height: 480 - //SystemPalette { id: palette } clip: true - - - + // Settings { property alias font: textFontDemoLowerCase.font; + property alias checkBoxScalableFonts: checkBoxScalableFonts.checked + property alias checkBoxNonScalableFonts: checkBoxNonScalableFonts.checked + property alias checkBoxMonospacedFonts: checkBoxMonospacedFonts.checked + property alias checkBoxProportionalFonts: checkBoxProportionalFonts.checked + } @@ -22,23 +22,23 @@ id: fontDialog visible: false modality: Qt.WindowModal - scalableFonts: fontDialogScalableFonts.checked - nonScalableFonts: fontDialogNonScalableFonts.checked - monospacedFonts: fontDialogMonospacedFonts.checked - proportionalFonts: fontDialogProportionalFonts.checked + scalableFonts: checkBoxScalableFonts.checked + nonScalableFonts: checkBoxNonScalableFonts.checked + monospacedFonts: checkBoxMonospacedFonts.checked + proportionalFonts: checkBoxProportionalFonts.checked title: qsTr("Choose a font") font: textFontDemoLowerCase.font currentFont: textFontDemoLowerCase.font - onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) } - onFontChanged: { console.log("FontChanged: " + font) } + //onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) } + //onFontChanged: { console.log("FontChanged: " + font) } onAccepted: { - console.log("Accepted: " + font); + //console.log("Accepted: " + font); textFontDemoLowerCase.font = currentFont; display.font = currentFont; //textFontDemoUpperCase.font = currentFont; //textFontDemoDigits.font = currentFont; } - onRejected: { console.log("Rejected") } + //onRejected: { console.log("Rejected") } } // ColumnLayout { @@ -88,24 +88,28 @@ columnSpacing: 8 CheckBox { - id: fontDialogScalableFonts + id: checkBoxScalableFonts text: "Scalable fonts" - Binding on checked { value: fontDialog.scalableFonts } + checked: true + //Binding on checked { value: fontDialog.scalableFonts } } CheckBox { - id: fontDialogNonScalableFonts + id: checkBoxNonScalableFonts text: "Non scalable fonts" - Binding on checked { value: fontDialog.nonScalableFonts } + checked: true + //Binding on checked { value: fontDialog.nonScalableFonts } } CheckBox { - id: fontDialogMonospacedFonts + id: checkBoxMonospacedFonts text: "Monospaced fonts" - Binding on checked { value: fontDialog.monospacedFonts } + checked: true + //Binding on checked { value: fontDialog.monospacedFonts } } CheckBox { - id: fontDialogProportionalFonts + id: checkBoxProportionalFonts text: "Proportional fonts" - Binding on checked { value: fontDialog.proportionalFonts } + checked: true + //Binding on checked { value: fontDialog.proportionalFonts } } } @@ -113,7 +117,12 @@ Button { text: qsTr("Change font") - onClicked: fontDialog.open() + onClicked: { + //We had to do this double magic cause otherwise our font list + //would not reflect our options. + fontDialog.setVisible(true); + fontDialog.open(); + } } } //ColumnLayout } //Item diff -r 40da62e57d85 -r 9903a5edeb56 MiniDisplay/minidisplay.cpp --- a/MiniDisplay/minidisplay.cpp Wed May 28 20:14:23 2014 +0200 +++ b/MiniDisplay/minidisplay.cpp Wed May 28 21:31:03 2014 +0200 @@ -122,8 +122,9 @@ iFont.setStyleStrategy(QFont::NoAntialias); QString strDemo="0123456789ABCDEF"; QFontMetrics metrics(iFont); - int w=metrics.width(strDemo); + int w=metrics.boundingRect(strDemo).width(); int h=metrics.height(); + //int h=metrics.boundingRect(strDemo).height(); QSize size(w,h); //Rendering in mono is quite broken we need RGB32 QImage image(size,QImage::Format_RGB32); @@ -131,7 +132,6 @@ //Draw some text into our image { QPainter painter(&image); - //painter.begin(&image); painter.setPen(0xFF000000); painter.setFont(iFont); painter.drawText(0,metrics.ascent(),strDemo);