diff options
-rw-r--r-- | components/Button.qml | 14 | ||||
-rw-r--r-- | components/CheckBox.qml | 1 | ||||
-rw-r--r-- | components/ComboBox.qml | 8 | ||||
-rw-r--r-- | components/GroupBox.qml | 9 | ||||
-rw-r--r-- | components/RadioButton.qml | 1 | ||||
-rw-r--r-- | components/SpinBox.qml | 3 | ||||
-rw-r--r-- | components/TabBar.qml | 6 | ||||
-rw-r--r-- | components/TableView.qml | 4 | ||||
-rw-r--r-- | components/TextArea.qml | 1 | ||||
-rw-r--r-- | components/TextField.qml | 2 | ||||
-rw-r--r-- | examples/Gallery.qml | 16 | ||||
-rw-r--r-- | examples/content/Panel.qml | 3 | ||||
-rw-r--r-- | src/qdesktopitem.cpp | 5 | ||||
-rw-r--r-- | src/qdesktopitem.h | 2 |
14 files changed, 61 insertions, 14 deletions
diff --git a/components/Button.qml b/components/Button.qml index 4ae591d1..730f2d05 100644 --- a/components/Button.qml +++ b/components/Button.qml @@ -59,14 +59,26 @@ BasicButton { sunken: pressed || checked raised: !(pressed || checked) hover: containsMouse - text: iconSource === "" ? "" : button.text +// text: iconSource === "" ? "" : button.text hasFocus: button.focus hint: button.styleHint // If no icon, let the style do the drawing activeControl: defaultbutton ? "default" : "f" + + Text { + id:text + color: textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + text: button.text + horizontalAlignment: Text.Center + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering + } } + // ## TODO: move to style implementation // label: Item { // // Used as a fallback since I can't pass the imageURL diff --git a/components/CheckBox.qml b/components/CheckBox.qml index 7a254dd9..27175517 100644 --- a/components/CheckBox.qml +++ b/components/CheckBox.qml @@ -81,6 +81,7 @@ FocusScope { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right elide: Text.ElideRight + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } } diff --git a/components/ComboBox.qml b/components/ComboBox.qml index 69aff685..4545a5ff 100644 --- a/components/ComboBox.qml +++ b/components/ComboBox.qml @@ -112,10 +112,16 @@ Private.BasicButton { raised: !sunken hover: comboBox.containsMouse enabled: comboBox.enabled - text: comboBox.selectedText + //text: comboBox.selectedText hasFocus: comboBox.focus contentHeight: 18 Component.onCompleted: popup.center = styleHint("comboboxpopup"); + Text { + id: textItem + text: comboBox.selectedText + anchors.centerIn: parent + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering + } } // ToDo: adjust margins so that selected popup label diff --git a/components/GroupBox.qml b/components/GroupBox.qml index c131a7f0..b0e4538e 100644 --- a/components/GroupBox.qml +++ b/components/GroupBox.qml @@ -66,13 +66,20 @@ Item { id: styleitem elementType: "groupbox" anchors.fill: parent - text: groupbox.title + //text: groupbox.title hover: checkbox.containsMouse on: checkbox.checked hasFocus: checkbox.activeFocus activeControl: checkable ? "checkbox" : "" sunken: !flat contentHeight: (title.length > 0 || checkable) ? 24 : 4 + Text { + id: textItem + text: groupbox.title + anchors.top: parent.top + anchors.left: parent.left + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering + } } Loader { diff --git a/components/RadioButton.qml b/components/RadioButton.qml index c6ff4a0f..c633ab01 100644 --- a/components/RadioButton.qml +++ b/components/RadioButton.qml @@ -67,6 +67,7 @@ CheckBox { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right elide: Text.ElideRight + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } } } diff --git a/components/SpinBox.qml b/components/SpinBox.qml index 8c07f596..0007450c 100644 --- a/components/SpinBox.qml +++ b/components/SpinBox.qml @@ -201,6 +201,7 @@ FocusScope { selectByMouse: true selectionColor: syspal.highlight selectedTextColor: syspal.highlightedText + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering // validator: DoubleValidator { bottom: minimumValue; top: maximumValue; } onAccepted: {setValue(input.text)} @@ -212,6 +213,8 @@ FocusScope { anchors.rightMargin: 4 anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering + } } diff --git a/components/TabBar.qml b/components/TabBar.qml index c5a923a4..c965d067 100644 --- a/components/TabBar.qml +++ b/components/TabBar.qml @@ -124,7 +124,7 @@ Item { elementType: "tab" selected: tab.selected info: tabbar.position - text: tabFrame.tabs[index].title +// text: tabFrame.tabs[index].title hover: mousearea.containsMouse hasFocus: tabbar.focus && selected property bool first: index === 0 @@ -137,11 +137,11 @@ Item { contentHeight: Math.max(style.fontHeight + tabVSpace + 6, 0) Text { id: textitem - // Used for size hint - visible: false + anchors.centerIn: parent onWidthChanged: updateRect() onHeightChanged: updateRect() text: tabFrame.tabs[index].title + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } } MouseArea { diff --git a/components/TableView.qml b/components/TableView.qml index 8df6fe9b..14bf1517 100644 --- a/components/TableView.qml +++ b/components/TableView.qml @@ -168,12 +168,14 @@ FocusScope{ elide: itemElideMode text: itemValue ? itemValue : "" color: itemForeground + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } Text { id: sizehint font: label.font text: itemValue ? itemValue : "" visible: false + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } } } @@ -432,7 +434,7 @@ FocusScope{ } - Text{ id:text } + Text{ id:text; renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } Item { id: tableColumn diff --git a/components/TextArea.qml b/components/TextArea.qml index b5deaa9d..b663ce10 100644 --- a/components/TextArea.qml +++ b/components/TextArea.qml @@ -79,6 +79,7 @@ ScrollArea { y: documentMargins // height has to be big enough to handle mouse focus height: Math.max(area.height, paintedHeight) + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering selectByMouse: true readOnly: false diff --git a/components/TextField.qml b/components/TextField.qml index c0d7bf8f..0d2d123a 100644 --- a/components/TextField.qml +++ b/components/TextField.qml @@ -168,6 +168,7 @@ FocusScope { selectByMouse:true selectionColor: syspal.highlight selectedTextColor: syspal.highlightedText + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering // Todo move these margins to StyleItem anchors.leftMargin: 4 @@ -194,5 +195,6 @@ FocusScope { clip: true elide: Text.ElideRight Behavior on opacity { NumberAnimation { duration: 90 } } + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } } diff --git a/examples/Gallery.qml b/examples/Gallery.qml index 1f282387..01e07989 100644 --- a/examples/Gallery.qml +++ b/examples/Gallery.qml @@ -110,6 +110,7 @@ Rectangle { anchors.margins: frame.margins width: parent.width horizontalAlignment: Text.AlignHCenter + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering text: { if (Desktop.screenCount == 1) { @@ -131,6 +132,7 @@ Rectangle { anchors.margins: frame.margins width: parent.width horizontalAlignment: Text.AlignHCenter + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering text: { var text = "The available dimensions of your screens are: " @@ -147,6 +149,7 @@ Rectangle { anchors.top: availableDimensionsText.bottom anchors.margins: frame.margins text: "This is a new Window, press the\nbutton below to close it again." + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } Button { anchors.horizontalCenter: closeText.horizontalCenter @@ -403,6 +406,7 @@ Rectangle { CheckBox { id: scale text: "Scale on hover" + property real scaleFactor: 2.0 } } } @@ -413,14 +417,14 @@ Rectangle { Button { width:200 text: "Push button" - scale: scale.checked && containsMouse ? 1.1 : 1 + scale: scale.checked && containsMouse ? scale.scaleFactor : 1 opacity: !fade.checked || containsMouse ? 1 : 0.5 Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } } Slider { value: 0.5 - scale: scale.checked && containsMouse ? 1.1 : 1 + scale: scale.checked && containsMouse ? scale.scaleFactor : 1 opacity: !fade.checked || containsMouse ? 1 : 0.5 Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } @@ -429,21 +433,21 @@ Rectangle { id : slider1 value: 50 tickmarksEnabled: false - scale: scale.checked && containsMouse ? 1.1 : 1 + scale: scale.checked && containsMouse ? scale.scaleFactor : 1 opacity: !fade.checked || containsMouse ? 1 : 0.5 Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } } ProgressBar { value: 0.5 - scale: scale.checked && containsMouse ? 1.1 : 1 + scale: scale.checked && containsMouse ? scale.scaleFactor : 1 opacity: !fade.checked || containsMouse ? 1 : 0.5 Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } } ProgressBar { indeterminate: true - scale: scale.checked && containsMouse ? 1.1 : 1 + scale: scale.checked && containsMouse ? scale.scaleFactor : 1 opacity: !fade.checked || containsMouse ? 1 : 0.5 Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } @@ -452,7 +456,7 @@ Rectangle { Dial{ width: 120 height: 120 - scale: scale.checked && containsMouse ? 1.1 : 1 + scale: scale.checked && containsMouse ? scale.scaleFactor : 1 opacity: !fade.checked || containsMouse ? 1 : 0.5 Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} } Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} } diff --git a/examples/content/Panel.qml b/examples/content/Panel.qml index 366e6f1d..e2f6c719 100644 --- a/examples/content/Panel.qml +++ b/examples/content/Panel.qml @@ -26,6 +26,7 @@ Rectangle { anchors.fill: parent anchors.margins: 40 text:textfield.text + renderType: Desktop.nativeTextRendering ? Text.NativeRendering : Text.QtRendering } Rectangle { border.color: "#444" @@ -69,7 +70,7 @@ Rectangle { spacing:12 Button { width: parent.width - 12; text: "Close Panel"; onClicked: sidebar.show = false} - TextField { id: textfield; text: "Some text" ; width: parent.width - 12} + TextField { id: textfield; text: "Some text" ; width: parent.width - 12; } SpinBox { width: parent.width - 12} CheckBox{ id: expander; text:"Sliders"} } diff --git a/src/qdesktopitem.cpp b/src/qdesktopitem.cpp index c0812152..d50fa1bc 100644 --- a/src/qdesktopitem.cpp +++ b/src/qdesktopitem.cpp @@ -80,6 +80,11 @@ int QDesktopItem::availableHeight() const return desktopWidget.availableGeometry().height(); } +bool QDesktopItem::nativeTextRendering() const +{ + return qgetenv("DESKTOPCOMPONENTS_USE_NATIVE_TEXT").toInt() != 0; +} + QDesktopItem *QDesktopItem::qmlAttachedProperties(QObject *obj) { return new QDesktopItem(obj); } diff --git a/src/qdesktopitem.h b/src/qdesktopitem.h index 76fdf4c6..3dabd4bb 100644 --- a/src/qdesktopitem.h +++ b/src/qdesktopitem.h @@ -53,6 +53,7 @@ class QDesktopItem : public QObject Q_PROPERTY(int availableWidth READ availableWidth NOTIFY availableGeometryChanged) Q_PROPERTY(int availableHeight READ availableHeight NOTIFY availableGeometryChanged) Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged) + Q_PROPERTY(bool nativeTextRendering READ nativeTextRendering CONSTANT) public: QDesktopItem(QObject* obj); @@ -64,6 +65,7 @@ public: int screenHeight() const; int availableWidth() const; int availableHeight() const; + bool nativeTextRendering() const; static QDesktopItem *qmlAttachedProperties(QObject *obj); private: |