diff --git a/src/declarativeimports/plasmacomponents3/ComboBox.qml b/src/declarativeimports/plasmacomponents3/ComboBox.qml index 1bae1bf61..63f748137 100644 --- a/src/declarativeimports/plasmacomponents3/ComboBox.qml +++ b/src/declarativeimports/plasmacomponents3/ComboBox.qml @@ -1,287 +1,287 @@ /* * Copyright 2016 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 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Templates @QQC2_VERSION@ as T import QtQuick.Controls @QQC2_VERSION@ as Controls import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.5 as Kirigami import "private" as Private import "mobiletextselection" as MobileTextSelection T.ComboBox { id: control implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding) + indicator.implicitWidth + rightPadding implicitHeight: units.gridUnit * 1.6 baselineOffset: contentItem.y + contentItem.baselineOffset hoverEnabled: true topPadding: surfaceNormal.margins.top leftPadding: surfaceNormal.margins.left rightPadding: surfaceNormal.margins.right + units.gridUnit * 2 bottomPadding: surfaceNormal.margins.bottom delegate: ItemDelegate { width: control.popup.width text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData highlighted: mouseArea.pressed ? listView.currentIndex == index : control.highlightedIndex == index property bool separatorVisible: false } indicator: PlasmaCore.SvgItem { implicitWidth: units.iconSizes.small implicitHeight: implicitWidth anchors { right: parent.right rightMargin: surfaceNormal.margins.right verticalCenter: parent.verticalCenter } svg: PlasmaCore.Svg { imagePath: "widgets/arrows" colorGroup: PlasmaCore.Theme.ButtonColorGroup } elementId: "down-arrow" } // contentItem: Label { // text: control.displayText // font: control.font // color: theme.buttonTextColor // horizontalAlignment: Text.AlignLeft // verticalAlignment: Text.AlignVCenter // elide: Text.ElideRight // } contentItem: MouseArea { id: mouseArea anchors.fill: parent acceptedButtons: Qt.LeftButton preventStealing: true property int indexUnderMouse: -1 onWheel: { if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) { control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1); } else { control.currentIndex = Math.max(control.currentIndex - 1, 0); } control.activated(control.currentIndex); } onPressed: { indexUnderMouse = -1; listView.currentIndex = control.highlightedIndex control.down = true; control.pressed = true; control.popup.visible = !control.popup.visible; } onReleased: { if (!containsMouse) { control.down = false; control.pressed = false; control.popup.visible = false; } if (indexUnderMouse > -1) { control.currentIndex = indexUnderMouse; } } onCanceled: { control.down = false; control.pressed = false; } onPositionChanged: { var pos = listView.mapFromItem(this, mouse.x, mouse.y); indexUnderMouse = listView.indexAt(pos.x, pos.y); listView.currentIndex = indexUnderMouse; controlRoot.activated(indexUnderMouse); } Connections { target: popup onClosed: { control.down = false; control.pressed = false; } } T.TextField { id: textField padding: 0 anchors { fill:parent leftMargin: control.leftPadding rightMargin: control.rightPadding topMargin: control.topPadding bottomMargin: control.bottomPadding } text: control.editable ? control.editText : control.displayText enabled: control.editable autoScroll: control.editable readOnly: control.down || !control.hasOwnProperty("editable") || !control.editable inputMethodHints: control.inputMethodHints validator: control.validator // Work around Qt bug where NativeRendering breaks for non-integer scale factors // https://bugreports.qt.io/browse/QTBUG-67007 renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering color: PlasmaCore.ColorScope.textColor selectionColor: Kirigami.Theme.highlightColor selectedTextColor: Kirigami.Theme.highlightedTextColor selectByMouse: !Kirigami.Settings.tabletMode cursorDelegate: Kirigami.Settings.tabletMode ? mobileCursor : undefined font: control.font horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter opacity: control.enabled ? 1 : 0.3 onFocusChanged: { if (focus) { MobileTextSelection.MobileTextActionsToolBar.controlRoot = textField; } } onTextChanged: MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible = false; onPressed: MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible = true; onPressAndHold: { if (!Kirigami.Settings.tabletMode) { return; } forceActiveFocus(); cursorPosition = positionAt(event.x, event.y); selectWord(); } } } Component { id: mobileCursor MobileTextSelection.MobileCursor { target: textField } } MobileTextSelection.MobileCursor { target: textField selectionStartHandle: true property var rect: textField.positionToRectangle(textField.selectionStart) //FIXME: this magic values seem to be always valid, for every font,every dpi, every scaling x: rect.x + 5 y: rect.y + 6 } background: PlasmaCore.FrameSvgItem { id: surfaceNormal //retrocompatibility with old controls implicitWidth: units.gridUnit * 6 anchors.fill: parent readonly property bool editable: control.hasOwnProperty("editable") && control.editable imagePath: editable ? "widgets/lineedit" : "widgets/button" prefix: editable ? "base" : (control.pressed ? "pressed" : "normal") Private.TextFieldFocus { visible: parent.editable z: -1 state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") anchors.fill: parent } Private.ButtonShadow { z: -1 visible: !parent.editable anchors.fill: parent state: { if (control.pressed) { return "hidden" } else if (control.hovered) { return "hover" } else if (control.activeFocus) { return "focus" } else { return "shadow" } } } MouseArea { anchors { fill: parent leftMargin: control.leftPadding rightMargin: control.rightPadding } acceptedButtons: Qt.NoButton onWheel: { if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) { control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1); } else { control.currentIndex = Math.max(control.currentIndex - 1, 0); } control.activated(control.currentIndex); } } } popup: T.Popup { x: control.mirrored ? control.width - width : 0 y: control.height width: Math.max(control.width, 150) implicitHeight: contentItem.implicitHeight topMargin: 6 bottomMargin: 6 contentItem: ListView { id: listView clip: true implicitHeight: contentHeight model: control.popup.visible ? control.delegateModel : null currentIndex: control.highlightedIndex highlightRangeMode: ListView.ApplyRange highlightMoveDuration: 0 // HACK: When the ComboBox is not inside a top-level Window, it's Popup does not inherit // the LayoutMirroring options. This is a workaround to fix this by enforcing // the LayoutMirroring options properly. // QTBUG: https://bugreports.qt.io/browse/QTBUG-66446 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true T.ScrollBar.vertical: Controls.ScrollBar { } } background: Rectangle { anchors { fill: parent margins: -1 } radius: 2 color: theme.viewBackgroundColor - border.color: Qt.rgba(theme.textColor.r, theme.textColor.g, theme.textColor.b, 0.3) + border.color: Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, 0.3) layer.enabled: true layer.effect: DropShadow { transparentBorder: true radius: 4 samples: 8 horizontalOffset: 2 verticalOffset: 2 color: Qt.rgba(0, 0, 0, 0.3) } } } } diff --git a/src/declarativeimports/plasmacomponents3/Dial.qml b/src/declarativeimports/plasmacomponents3/Dial.qml index 7589d8ef6..1d52efa49 100644 --- a/src/declarativeimports/plasmacomponents3/Dial.qml +++ b/src/declarativeimports/plasmacomponents3/Dial.qml @@ -1,102 +1,102 @@ /* * Copyright 2016 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 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Templates @QQC2_VERSION@ as T import org.kde.plasma.core 2.0 as PlasmaCore import "private" as Private T.Dial { id: control implicitWidth: units.gridUnit * 5 implicitHeight: implicitWidth hoverEnabled: true onPositionChanged: canvas.requestPaint() background:Canvas { id: canvas width: control.availableWidth height: control.availableHeight onPaint: { var ctx = getContext("2d"); ctx.reset(); var centreX = width / 2; var centreY = height / 2; ctx.globalAlpha = 0.3; ctx.beginPath(); - ctx.strokeStyle = theme.textColor; + ctx.strokeStyle = control.PlasmaCore.ColorScope.textColor; ctx.lineWidth=5; ctx.arc(centreX, centreY, width/2.4, 0, 2*Math.PI, false); ctx.stroke(); ctx.globalAlpha = 1; ctx.beginPath(); - ctx.strokeStyle = theme.highlightColor; + ctx.strokeStyle = control.PlasmaCore.ColorScope.highlightColor; ctx.lineWidth=5; ctx.arc(centreX, centreY, width/2.4, 0.7*Math.PI, 1.6*Math.PI * control.position - 1.25*Math.PI, false); ctx.stroke(); } } PlasmaCore.Svg { id: grooveSvg imagePath: "widgets/slider" colorGroup: PlasmaCore.ColorScope.colorGroup } handle: Item { x: (control.width/2) + Math.cos((-(control.angle-90)*Math.PI)/180) * (control.width/2-width/2) - width/2 y: (control.height/2) + Math.sin(((control.angle-90)*Math.PI)/180) * (control.height/2-height/2) - height/2 implicitHeight: Math.floor(units.gridUnit*1.6) implicitWidth: implicitHeight Private.RoundShadow { id: roundShadow anchors.fill: parent state: { if (control.pressed) { return "hidden" } else if (control.hovered) { return "hover" } else if (control.activeFocus) { return "focus" } else { return "shadow" } } } PlasmaCore.SvgItem { svg: PlasmaCore.Svg { id: buttonSvg imagePath: "widgets/actionbutton" } elementId: control.pressed? "pressed" : "normal" width: Math.floor(parent.height/2) * 2 height: width anchors.centerIn: parent Behavior on opacity { NumberAnimation { duration: units.longDuration } } } } } diff --git a/src/declarativeimports/plasmacomponents3/TabButton.qml b/src/declarativeimports/plasmacomponents3/TabButton.qml index 61ec49863..af892f3a6 100644 --- a/src/declarativeimports/plasmacomponents3/TabButton.qml +++ b/src/declarativeimports/plasmacomponents3/TabButton.qml @@ -1,48 +1,48 @@ /* * Copyright 2016 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 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Controls @QQC2_VERSION@ import QtQml.Models 2.1 import QtQuick.Templates @QQC2_VERSION@ as T import org.kde.plasma.core 2.0 as PlasmaCore T.TabButton { id: control implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding baselineOffset: contentItem.y + contentItem.baselineOffset padding: units.smallSpacing hoverEnabled: true contentItem: Label { text: control.text font: control.font elide: Text.ElideRight opacity: enabled ? 1 : 0.3 - color: theme.textColor + color: PlasmaCore.ColorScope.textColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } background: Item {} } diff --git a/src/declarativeimports/plasmastyle/GroupBoxStyle.qml b/src/declarativeimports/plasmastyle/GroupBoxStyle.qml index 430d50942..fd447b670 100644 --- a/src/declarativeimports/plasmastyle/GroupBoxStyle.qml +++ b/src/declarativeimports/plasmastyle/GroupBoxStyle.qml @@ -1,70 +1,70 @@ /* * Copyright 2014 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.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 import QtQuick.Controls.Styles 1.2 as QtQuickControlStyle import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents //GroupBoxStyle is not exported Style { id: styleRoot - property color textColor: theme.textColor + property color textColor: PlasmaCore.ColorScope.textColor property Component checkbox: PlasmaComponents.CheckBox { checked: control.checked } property Component panel: Item { anchors.fill: parent Loader { id: checkboxloader anchors.left: parent.left sourceComponent: control.checkable ? checkbox : null anchors.verticalCenter: label.verticalCenter width: item ? item.implicitWidth : 0 } PlasmaComponents.Label { id: label anchors.top: parent.top anchors.left: checkboxloader.right anchors.margins: units.smallSpacing text: control.title } PlasmaCore.FrameSvgItem { id: frame anchors.fill: parent imagePath: "widgets/frame" prefix: "plain" visible: !control.flat colorGroup: PlasmaCore.ColorScope.colorGroup Component.onCompleted: { styleRoot.padding.left = frame.margins.left styleRoot.padding.top = frame.margins.top + label.height styleRoot.padding.right = frame.margins.right styleRoot.padding.bottom = frame.margins.bottom } } } } diff --git a/src/declarativeimports/plasmastyle/StatusBarStyle.qml b/src/declarativeimports/plasmastyle/StatusBarStyle.qml index 42dc39b2d..6370a3ccb 100644 --- a/src/declarativeimports/plasmastyle/StatusBarStyle.qml +++ b/src/declarativeimports/plasmastyle/StatusBarStyle.qml @@ -1,47 +1,47 @@ /* * Copyright 2014 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.2 import QtQuick.Controls.Styles 1.2 as QtQuickControlStyle import QtQuick.Controls 1.2 import org.kde.plasma.core 2.0 as PlasmaCore QtQuickControlStyle.StatusBarStyle { padding { left: units.smallSpacing right: units.smallSpacing top: units.smallSpacing bottom: units.smallSpacing/2 } background: Item { implicitHeight: 16 implicitWidth: 200 Rectangle { anchors.top: parent.top width: parent.width height: 1 - color: theme.textColor + color: PlasmaCore.ColorScope.textColor opacity: 0.1 } } }