diff --git a/examples/applets/testtheme/contents/ui/FontGizmo.qml b/examples/applets/testtheme/contents/ui/FontGizmo.qml index ed753c8e1..46c249e4d 100644 --- a/examples/applets/testtheme/contents/ui/FontGizmo.qml +++ b/examples/applets/testtheme/contents/ui/FontGizmo.qml @@ -1,66 +1,68 @@ /* * Copyright 2014 Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.1 +import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate + import org.kde.plasma.core 2.0 as PlasmaCore //import org.kde.plasma.components 2.0 as PlasmaComponents //import org.kde.plasma.extras 2.0 as PlasmaExtras //import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons Text { - renderType: Text.NativeRendering + renderType: QtQuickControlsPrivate.Settings.isMobile ? Text.QtRendering : Text.NativeRendering font.pointSize: 22 //font.family: theme.defaultFont.family font.family: fontCheck.text font.weight: lightCheck.checked ? Font.Light : Font.Normal text: "Lesley 40:83 - (" + font.family + ")" height: paintedHeightCheck.checked ? paintedHeight : 22 //anchors.fill: parent //spacing: units.smallSpacing/2 verticalAlignment: Text.AlignTop Rectangle { color: "yellow" visible: boxesCheck.checked height: 1 width: paintedWidth anchors { verticalCenter: parent.verticalCenter left: parent.left } } Rectangle { color: "transparent" border.width: 1 border.color: "green" visible: boxesCheck.checked height: parent.paintedHeight width: paintedWidth anchors { top: parent.top left: parent.left } } } diff --git a/src/declarativeimports/plasmacomponents/qml/Label.qml b/src/declarativeimports/plasmacomponents/qml/Label.qml index a22efb6e6..9c408856e 100644 --- a/src/declarativeimports/plasmacomponents/qml/Label.qml +++ b/src/declarativeimports/plasmacomponents/qml/Label.qml @@ -1,59 +1,60 @@ /* * Copyright (C) 2011 by Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.1 +import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate import org.kde.plasma.core 2.0 as PlasmaCore /** * This is a label which uses the plasma theme. * * The characteristics of the text will be automatically set according to the * plasma theme. If you need a more customized text item use the Text component * from QtQuick. * * You can use all elements of the QML Text component, in particular the "text" * property to define the label text. * * @inherit QtQuick.Text */ Text { id: root height: Math.round(Math.max(paintedHeight, theme.mSize(theme.defaultFont).height*1.6)) verticalAlignment: lineCount > 1 ? Text.AlignTop : Text.AlignVCenter activeFocusOnTab: false - renderType: Text.NativeRendering + renderType: QtQuickControlsPrivate.Settings.isMobile ? Text.QtRendering : Text.NativeRendering font.capitalization: theme.defaultFont.capitalization font.family: theme.defaultFont.family font.italic: theme.defaultFont.italic font.letterSpacing: theme.defaultFont.letterSpacing font.pointSize: theme.defaultFont.pointSize font.strikeout: theme.defaultFont.strikeout font.underline: theme.defaultFont.underline font.weight: theme.defaultFont.weight font.wordSpacing: theme.defaultFont.wordSpacing color: PlasmaCore.ColorScope.textColor opacity: enabled? 1 : 0.6 Accessible.role: Accessible.StaticText Accessible.name: text } diff --git a/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml b/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml index b55243e86..f7210c281 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml @@ -1,125 +1,126 @@ /* * Copyright (C) 2011 by Daker Fernandes Pinheiro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.1 +import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate import org.kde.plasma.core 2.0 as PlasmaCore /** * Private base component for several public components. Any element documented here * can be used in components inheriting from DualStateButton. */ Item { id: dualButton // Common API /** * If the button is checked, its checked property is true; otherwise false. The property is false by default. */ property bool checked /** * type:bool * If the button is pressed, its pressed property is true. * @see clicked */ property alias pressed: mouseArea.pressed /** * Emitted when the user clicked a mouse button over the button (or * tapped on the touch screen) */ signal clicked() // Plasma API /** * The text is shown beside the button. By default text is an empty string. */ property alias text: label.text // TODO: Not yet part of the common API property alias view: surfaceLoader.sourceComponent property alias shadow: shadowLoader.sourceComponent width: surfaceLoader.width + label.paintedWidth height: theme.mSize(theme.defaultFont).height*1.6 // TODO: needs to define if there will be specific graphics for // disabled buttons opacity: dualButton.enabled ? 1.0 : 0.5 function released() { if (dualButton.enabled) { dualButton.checked = !dualButton.checked; dualButton.clicked(); } } Keys.onReleased: { if(event.key == Qt.Key_Space || event.key == Qt.Key_Return) released(); } Loader { id: shadowLoader anchors.fill: surfaceLoader state: (dualButton.enabled && (dualButton.focus || mouseArea.containsMouse)) ? "hover" : "shadow" } Loader { id: surfaceLoader anchors { verticalCenter: parent.verticalCenter left: text ? parent.left : undefined horizontalCenter: text ? undefined : parent.horizontalCenter } } Text { id: label text: dualButton.text - renderType: Text.NativeRendering + renderType: QtQuickControlsPrivate.Settings.isMobile ? Text.QtRendering : Text.NativeRendering anchors { top: parent.top bottom: parent.bottom left: surfaceLoader.right right: parent.right //FIXME: see how this margin will be set leftMargin: height/4 } color: theme.textColor verticalAlignment: Text.AlignVCenter } MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true onPressed: dualButton.forceActiveFocus(); onReleased: dualButton.released(); } Accessible.name: text Accessible.checkable: checkable Accessible.checked: checked function accessiblePressAction() { dualButton.forceActiveFocus() dualButton.released() } } diff --git a/src/declarativeimports/plasmastyle/SpinBoxStyle.qml b/src/declarativeimports/plasmastyle/SpinBoxStyle.qml index 01f18adbb..45165af25 100644 --- a/src/declarativeimports/plasmastyle/SpinBoxStyle.qml +++ b/src/declarativeimports/plasmastyle/SpinBoxStyle.qml @@ -1,90 +1,91 @@ /* * Copyright 2014 by Marco Martin * Copyright 2014 by David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle +import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.components 2.0 as PlasmaComponents import "private" as Private QtQuickControlStyle.SpinBoxStyle { id: styleRoot horizontalAlignment: Qt.AlignRight textColor: theme.viewTextColor selectionColor: theme.viewFocusColor selectedTextColor: theme.viewBackgroundColor - renderType: Text.NativeRendering + renderType: QtQuickControlsPrivate.Settings.isMobile ? Text.QtRendering : Text.NativeRendering PlasmaCore.Svg { id: arrowSvg imagePath: "widgets/arrows" colorGroup: PlasmaCore.Theme.ButtonColorGroup } incrementControl: PlasmaCore.SvgItem { anchors { fill: parent margins : 1 leftMargin: -1 rightMargin: 3 } svg: arrowSvg elementId: "up-arrow" opacity: control.enabled ? (styleData.upPressed ? 1 : 0.6) : 0.5 } decrementControl: PlasmaCore.SvgItem { anchors { fill: parent margins : 1 leftMargin: -1 rightMargin: 3 } svg: arrowSvg elementId: "down-arrow" opacity: control.enabled ? (styleData.downPressed ? 1 : 0.6) : 0.5 } background: Item { implicitHeight: theme.mSize(theme.defaultFont).height * 1.6 implicitWidth: theme.mSize(theme.defaultFont).width * 12 Private.TextFieldFocus { id: hover state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") anchors.fill: base } PlasmaCore.FrameSvgItem { id: base anchors.fill: parent imagePath: "widgets/lineedit" prefix: "base" } } } diff --git a/src/declarativeimports/plasmastyle/TextAreaStyle.qml b/src/declarativeimports/plasmastyle/TextAreaStyle.qml index 394326e73..3b4cb917f 100644 --- a/src/declarativeimports/plasmastyle/TextAreaStyle.qml +++ b/src/declarativeimports/plasmastyle/TextAreaStyle.qml @@ -1,84 +1,84 @@ /* * Copyright (C) 2014 by Marco MArtin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.1 import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate import QtQuick.Controls 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import "private" as Private QtQuickControlStyle.TextAreaStyle { id: style ScrollViewStyle { id: svs } font: theme.defaultFont backgroundColor: "transparent" textColor: control.backgroundVisible ? theme.viewTextColor : PlasmaCore.ColorScope.textColor selectionColor: control.backgroundVisible ? theme.viewFocusColor : PlasmaCore.ColorScope.highlightColor selectedTextColor: control.backgroundVisible ? theme.viewHighlightedTextColor : PlasmaCore.ColorScope.highlightedTextColor - renderType: Text.NativeRendering + renderType: QtQuickControlsPrivate.Settings.isMobile ? Text.QtRendering : Text.NativeRendering frame: PlasmaCore.FrameSvgItem { id: base anchors.fill: parent visible: control.backgroundVisible imagePath: "widgets/lineedit" prefix: "base" Private.TextFieldFocus { id: hover state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") anchors.fill: base } Component.onCompleted: { style.padding.left = base.margins.left style.padding.top = base.margins.top //TODO: if QtControls gets a component for this, use it instead of this hardcoded heuristic style.padding.right = base.margins.right + (control.clearButtonShown ? Math.max(control.parent.height*0.8, units.iconSizes.small)+units.smallSpacing : 0) style.padding.bottom = base.margins.bottom } } scrollBarBackground: svs.scrollBarBackground handle: svs.handle incrementControl: svs.incrementControl decrementControl: svs.decrementControl Component { id: editMenuTouch EditMenuTouch {} } Component { id: cursorTouch CursorDelegate {} } __cursorHandle: CursorHandleStyle {} __cursorDelegate: QtQuickControlsPrivate.Settings.isMobile ? cursorTouch : null __selectionHandle: SelectionHandleStyle {} property Component __editMenu: QtQuickControlsPrivate.Settings.isMobile ? editMenuTouch : null } diff --git a/src/declarativeimports/plasmastyle/TextFieldStyle.qml b/src/declarativeimports/plasmastyle/TextFieldStyle.qml index a26ae9ce1..504b5b841 100644 --- a/src/declarativeimports/plasmastyle/TextFieldStyle.qml +++ b/src/declarativeimports/plasmastyle/TextFieldStyle.qml @@ -1,96 +1,97 @@ /* * Copyright (C) 2014 by Marco MArtin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import "private" as Private QtQuickControlStyle.TextFieldStyle { id: root textColor: control.enabled ? theme.viewTextColor : Qt.rgba(theme.viewTextColor.r, theme.viewTextColor.g, theme.viewTextColor.b, 0.6) selectionColor: theme.viewFocusColor selectedTextColor: theme.viewHighlightedTextColor placeholderTextColor: Qt.rgba(theme.viewTextColor.r, theme.viewTextColor.g, theme.viewTextColor.b, 0.5) /* * Since the password echo is a circle woithout vertical or horizontal lines, it won't be * more blurred with different rendring types. * Using Qt rendering, the dots will look more aligned and equally spaced. + * Also if we are on mobile, make sure we use QtRendering */ - renderType: control.echoMode == TextInput.Normal ? Text.NativeRendering : Text.QtRendering + renderType: !QtQuickControlsPrivate.Settings.isMobile && control.echoMode == TextInput.Normal ? Text.NativeRendering : Text.QtRendering background: Item { //QQC button heights are max(backgroundHeight, label + margins). //QQC lineedits are only from the background (and if background is not set, just an arbirtary value of 25) //Why? I don't know //In order to get the same height in both buttons and lineedits we need to apply the same rule here implicitHeight: Math.max(control.cursorRectangle.height * 1.6, control.cursorRectangle.height + base.margins.top + base.margins.bottom) implicitWidth: theme.mSize(theme.defaultFont).width * 12 opacity: control.enabled ? 1 : 0.6 Private.TextFieldFocus { id: hover state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") anchors.fill: base } PlasmaCore.FrameSvgItem { id: base anchors.fill: parent imagePath: "widgets/lineedit" prefix: "base" } Component.onCompleted: { root.padding.left = base.margins.left root.padding.top = base.margins.top root.padding.bottom = base.margins.bottom //TODO: if QtControls gets a component for this, use it instead of this hardcoded heuristic root.padding.right = Qt.binding(function() { var actionIconSize = Math.max(textField.height * 0.8, units.iconSizes.small); //actionCount is an int of the number of items var actionCount = (control.hasOwnProperty("clearButtonShown") && control.clearButtonShown) + (control.hasOwnProperty("__effectiveRevealPasswordButtonShown") && control.__effectiveRevealPasswordButtonShown); return base.margins.right + (actionIconSize * actionCount) + (actionCount > 0 ? units.smallSpacing : 0); }) } } Component { id: editMenuTouch EditMenuTouch {} } Component { id: cursorTouch CursorDelegate {} } __cursorHandle: CursorHandleStyle {} __cursorDelegate: QtQuickControlsPrivate.Settings.isMobile ? cursorTouch : null __selectionHandle: SelectionHandleStyle {} property Component __editMenu: QtQuickControlsPrivate.Settings.isMobile ? editMenuTouch : null }