diff --git a/src/declarativeimports/CMakeLists.txt b/src/declarativeimports/CMakeLists.txt --- a/src/declarativeimports/CMakeLists.txt +++ b/src/declarativeimports/CMakeLists.txt @@ -6,3 +6,40 @@ add_subdirectory(calendar) install(DIRECTORY plasmastyle/ DESTINATION ${KDE_INSTALL_QMLDIR}/QtQuick/Controls/Styles/Plasma) + + +#install the components as a QQC2 Style, as style for applications (mainly for Plasma Mobile) +install(DIRECTORY plasmacomponents3/ DESTINATION ${KDE_INSTALL_QMLDIR}/QtQuick/Controls.2/Plasma PATTERN qmldir EXCLUDE) + +#install some of the componets as a separate import, to be used in plasmoids (some of them like ApplicationWindow are of no use for plasmoids) +install(FILES plasmacomponents3/BusyIndicator.qml + plasmacomponents3/Button.qml + plasmacomponents3/CheckBox.qml + plasmacomponents3/CheckDelegate.qml + plasmacomponents3/CheckIndicator.qml + #combobox is not in a new window, but maybe better already than the broken qqc1 combobox? + plasmacomponents3/ComboBox.qml + plasmacomponents3/Container.qml + plasmacomponents3/Control.qml + plasmacomponents3/Dial.qml + plasmacomponents3/Frame.qml + plasmacomponents3/GroupBox.qml + plasmacomponents3/ItemDelegate.qml + plasmacomponents3/Label.qml + + plasmacomponents3/ProgressBar.qml + plasmacomponents3/RadioButton.qml + plasmacomponents3/RadioDelegate.qml + plasmacomponents3/RadioIndicator.qml + plasmacomponents3/RangeSlider.qml + plasmacomponents3/ScrollBar.qml + plasmacomponents3/Slider.qml + plasmacomponents3/SpinBox.qml + plasmacomponents3/TabBar.qml + plasmacomponents3/TabButton.qml + plasmacomponents3/TextArea.qml + plasmacomponents3/TextField.qml + plasmacomponents3/ToolBar.qml + plasmacomponents3/ToolButton.qml + + DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/components.3) diff --git a/src/declarativeimports/plasmacomponents3/BusyIndicator.qml b/src/declarativeimports/plasmacomponents3/BusyIndicator.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/BusyIndicator.qml @@ -0,0 +1,61 @@ +/* +* Copyright (C) 2014 Kai Uwe Broulik +* 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 2.010-1301, USA. +*/ + +import QtQuick 2.2 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.BusyIndicator { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding + + padding: units.smallSpacing + + contentItem: PlasmaCore.SvgItem { + id: indicatorItem + svg: PlasmaCore.Svg { + imagePath: "widgets/busywidget" + colorGroup: PlasmaCore.ColorScope.colorGroup + } + elementId: "busywidget" + + implicitWidth: units.gridUnit * 2 + implicitHeight: width + + Connections { + target: control + onRunningChanged: { + rotationAnimator.from = rotation + rotationAnimator.to = rotation + 360 + } + } + + RotationAnimator on rotation { + id: rotationAnimator + from: 0 + to: 360 + duration: 1500 + running: control.running && indicatorItem.visible && indicatorItem.opacity > 0; + loops: Animation.Infinite + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/Button.qml b/src/declarativeimports/plasmacomponents3/Button.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Button.qml @@ -0,0 +1,93 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +T.Button { + id: control + + implicitWidth: Math.max(background.implicitWidth, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) + + leftPadding: surfaceNormal.margins.left + topPadding: surfaceNormal.margins.top + rightPadding: surfaceNormal.margins.right + bottomPadding: surfaceNormal.margins.bottom + + hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? + + contentItem: Label { + text: control.text + font: control.font + opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 + color: theme.buttonTextColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Item { + //retrocompatibility with old controls + implicitWidth: units.gridUnit * 6 + implicitHeight: units.gridUnit * 1.6 + Private.ButtonShadow { + 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.FrameSvgItem { + id: surfaceNormal + anchors.fill: parent + imagePath: "widgets/button" + prefix: "normal" + opacity: control.checked || control.pressed ? 0 : 1 + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + PlasmaCore.FrameSvgItem { + anchors.fill: parent + imagePath: "widgets/button" + prefix: "pressed" + opacity: control.checked || control.pressed ? 1 : 0 + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/CheckBox.qml b/src/declarativeimports/plasmacomponents3/CheckBox.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/CheckBox.qml @@ -0,0 +1,62 @@ +/* + * 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 2.0 as T +import QtQuick.Controls 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +T.CheckBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 1 + spacing: Math.round(units.gridUnit / 8) + + hoverEnabled: true + + indicator: CheckIndicator { + LayoutMirroring.enabled: control.mirrored + LayoutMirroring.childrenInherit: true + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + } + control: control + } + + contentItem: Label { + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + opacity: control.enabled ? 1 : 0.6 + text: control.text + font: control.font + color: PlasmaCore.ColorScope.textColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } +} diff --git a/src/declarativeimports/plasmacomponents3/CheckDelegate.qml b/src/declarativeimports/plasmacomponents3/CheckDelegate.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/CheckDelegate.qml @@ -0,0 +1,60 @@ +/* + * 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.5 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" + +T.CheckDelegate { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding + hoverEnabled: true + + topPadding: background.margins.top + bottomPadding: background.margins.bottom + leftPadding: background.margins.left + rightPadding: background.margins.right + spacing: units.smallSpacing + + contentItem: Label { + leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + + text: control.text + font: control.font + color: theme.viewTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + indicator: CheckIndicator { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + control: control + } + + background: DefaultListItemBackground {} +} diff --git a/src/declarativeimports/plasmacomponents3/CheckIndicator.qml b/src/declarativeimports/plasmacomponents3/CheckIndicator.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/CheckIndicator.qml @@ -0,0 +1,64 @@ +/* + * 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 org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +PlasmaCore.FrameSvgItem { + id: root + property Item control + imagePath: "widgets/button" + prefix: "normal" + implicitWidth: units.gridUnit + implicitHeight: units.gridUnit + opacity: control.enabled ? 1 : 0.6 + + PlasmaCore.SvgItem { + svg: PlasmaCore.Svg { + id: checkmarkSvg + imagePath: "widgets/checkmarks" + } + elementId: "checkbox" + opacity: { + switch (control.checkState) { + case Qt.Checked: + return 1; + case Qt.PartiallyChecked: + return 0.5; + default: + return 0; + } + } + anchors { + fill: parent + } + Behavior on opacity { + NumberAnimation { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + Private.ButtonShadow { + z: -1 + anchors.fill: parent + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") + } +} diff --git a/src/declarativeimports/plasmacomponents3/ComboBox.qml b/src/declarativeimports/plasmacomponents3/ComboBox.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ComboBox.qml @@ -0,0 +1,133 @@ +/* + * 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 2.0 as T +import QtQuick.Controls 2.0 as Controls +import QtGraphicalEffects 1.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +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 + 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: 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 + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: PlasmaCore.FrameSvgItem { + id: surfaceNormal + //retrocompatibility with old controls + implicitWidth: units.gridUnit * 6 + anchors.fill: parent + imagePath: "widgets/button" + prefix: control.pressed ? "pressed" : "normal" + Private.ButtonShadow { + z: -1 + anchors.fill: parent + state: { + if (control.pressed) { + return "hidden" + } else if (control.hovered) { + return "hover" + } else if (control.activeFocus) { + return "focus" + } else { + return "shadow" + } + } + } + } + + popup: T.Popup { + 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 + 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) + 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/Container.qml b/src/declarativeimports/plasmacomponents3/Container.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Container.qml @@ -0,0 +1,30 @@ +/* + * 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 2.0 as T + +T.Container { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + (contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding) +} diff --git a/src/declarativeimports/plasmacomponents3/Control.qml b/src/declarativeimports/plasmacomponents3/Control.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Control.qml @@ -0,0 +1,30 @@ +/* + * 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 2.0 as T + +T.Control { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + (contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding) +} diff --git a/src/declarativeimports/plasmacomponents3/Dial.qml b/src/declarativeimports/plasmacomponents3/Dial.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Dial.qml @@ -0,0 +1,83 @@ +/* + * 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 2.0 as T +import QtQuick.Controls.impl 2.0 +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 + + background: DialRing { + width: control.availableWidth + height: control.availableHeight + color: control.visualFocus ? theme.highlightColor : theme.textColor + progress: control.position + opacity: control.enabled ? 0.5 : 0.3 + } + + 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/Dialog.qml b/src/declarativeimports/plasmacomponents3/Dialog.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Dialog.qml @@ -0,0 +1,70 @@ +/* + * 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 2.1 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Dialog { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentWidth > 0 ? contentHeight + topPadding + bottomPadding : 0) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + leftPadding: background.margins.left + topPadding: background.margins.top + rightPadding: background.margins.right + bottomPadding: background.margins.bottom + + enter: Transition { + NumberAnimation { + property: "opacity" + from: 0 + to: 1 + easing.type: Easing.InOutQuad + duration: 250 + } + } + + exit: Transition { + NumberAnimation { + property: "opacity" + from: 1 + to: 0 + easing.type: Easing.InOutQuad + duration: 250 + } + } + + contentItem: Item { } + + background: PlasmaCore.FrameSvgItem { + implicitWidth: units.gridUnit * 12 + imagePath: "widgets/background" + } + + footer: DialogButtonBox { + position: DialogButtonBox.Footer + } +} diff --git a/src/declarativeimports/plasmacomponents3/DialogButtonBox.qml b/src/declarativeimports/plasmacomponents3/DialogButtonBox.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/DialogButtonBox.qml @@ -0,0 +1,53 @@ +/* + * 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 2.1 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.DialogButtonBox { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding + + spacing: units.smallSpacing + leftPadding: parent.leftPadding + topPadding: parent.topPadding + rightPadding: parent.rightPadding + bottomPadding: parent.bottomPadding + alignment: Qt.AlignRight + + delegate: Button { + width: Math.min(implicitWidth, control.width / control.count - control.rightPadding - control.spacing * (control.count-1)) + } + + contentItem: ListView { + implicitWidth: contentWidth + implicitHeight: units.gridUnit * 1.6 + + model: control.contentModel + spacing: control.spacing + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + snapMode: ListView.SnapToItem + } + + background: Item {} +} diff --git a/src/declarativeimports/plasmacomponents3/Drawer.qml b/src/declarativeimports/plasmacomponents3/Drawer.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Drawer.qml @@ -0,0 +1,75 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Drawer { + id: control + + parent: T.ApplicationWindow.overlay + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + topPadding: control.edge === Qt.BottomEdge ? Math.round(units.devicePixelRatio) : 0 + leftPadding: control.edge === Qt.RightEdge ? Math.round(units.devicePixelRatio) : 0 + rightPadding: control.edge === Qt.LeftEdge ? Math.round(units.devicePixelRatio) : 0 + bottomPadding: control.edge === Qt.TopEdge ? Math.round(units.devicePixelRatio) : 0 + + background: PlasmaCore.FrameSvgItem { + anchors { + fill: parent + leftMargin: -margins.left + topMargin: -margins.top + rightMargin: -margins.right + bottomMargin: -margins.bottom + } + implicitWidth: units.gridUnit * 12 + imagePath: "widgets/background" + enabledBorders: { + switch (control.edge) { + case Qt.BottomEdge: + return PlasmaCore.FrameSvgItem.TopBorder; + case Qt.RightEdge: + return PlasmaCore.FrameSvgItem.LeftBorder; + case Qt.TopEdge: + return PlasmaCore.FrameSvgItem.BottomBorder; + case Qt.LeftEdge: + default: + return PlasmaCore.FrameSvgItem.RightBorder; + } + } + } + + enter: Transition { + SmoothedAnimation { + velocity: 5 + } + } + exit: Transition { + SmoothedAnimation { + velocity: 5 + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/Frame.qml b/src/declarativeimports/plasmacomponents3/Frame.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Frame.qml @@ -0,0 +1,40 @@ +/* + * 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 2.0 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Frame { + id: control + + implicitWidth: contentWidth + leftPadding + rightPadding + implicitHeight: contentHeight + topPadding + bottomPadding + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + padding: units.smallSpacing + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/frame" + prefix: "plain" + } +} diff --git a/src/declarativeimports/plasmacomponents3/GroupBox.qml b/src/declarativeimports/plasmacomponents3/GroupBox.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/GroupBox.qml @@ -0,0 +1,53 @@ +/* + * 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 2.0 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.GroupBox { + id: control + + implicitWidth: contentWidth + leftPadding + rightPadding + implicitHeight: contentHeight + topPadding + bottomPadding + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + padding: 6 + topPadding: padding + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0) + + label: Label { + x: control.leftPadding + width: control.availableWidth + + text: control.title + font: control.font + color: SystemPaletteSingleton.text(control.enabled) + elide: Text.ElideRight + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/frame" + prefix: "plain" + } +} diff --git a/src/declarativeimports/plasmacomponents3/ItemDelegate.qml b/src/declarativeimports/plasmacomponents3/ItemDelegate.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ItemDelegate.qml @@ -0,0 +1,53 @@ +/* + * 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.5 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" + +T.CheckDelegate { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding + hoverEnabled: true + + topPadding: background.margins.top + bottomPadding: background.margins.bottom + leftPadding: background.margins.left + rightPadding: background.margins.right + spacing: units.smallSpacing + + contentItem: Label { + leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + + text: control.text + font: control.font + color: theme.viewTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + background: DefaultListItemBackground {} +} diff --git a/src/declarativeimports/plasmacomponents3/Label.qml b/src/declarativeimports/plasmacomponents3/Label.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Label.qml @@ -0,0 +1,41 @@ +/* + * 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.1 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Label { + id: control + + verticalAlignment: lineCount > 1 ? Text.AlignTop : Text.AlignVCenter + + activeFocusOnTab: false + renderType: Text.NativeRendering + + //font data is the system one by default + //TODO: from theme singleton? + color: PlasmaCore.ColorScope.textColor + linkColor: theme.linkColor + + opacity: enabled? 1 : 0.6 + + Accessible.role: Accessible.StaticText + Accessible.name: text +} diff --git a/src/declarativeimports/plasmacomponents3/Menu.qml b/src/declarativeimports/plasmacomponents3/Menu.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Menu.qml @@ -0,0 +1,74 @@ +/* + * 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 2.0 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Menu { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding + + margins: 0 + leftPadding: background.margins.left + topPadding: background.margins.top + rightPadding: background.margins.right + bottomPadding: background.margins.bottom + + contentItem: ListView { + implicitHeight: contentHeight + model: control.contentModel + clip: true + keyNavigationWraps: false + currentIndex: -1 + + T.ScrollBar.vertical: ScrollBar {} + } + + enter: Transition { + NumberAnimation { + property: "opacity" + from: 0 + to: 1 + easing.type: Easing.InOutQuad + duration: 150 + } + } + + exit: Transition { + NumberAnimation { + property: "opacity" + from: 1 + to: 0 + easing.type: Easing.InOutQuad + duration: 150 + } + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/background" + implicitWidth: units.gridUnit * 8 + implicitHeight: units.gridUnit * 2 + } +} diff --git a/src/declarativeimports/plasmacomponents3/MenuItem.qml b/src/declarativeimports/plasmacomponents3/MenuItem.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/MenuItem.qml @@ -0,0 +1,79 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.MenuItem { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + leftPadding: highlight.margins.left + topPadding: highlight.margins.top + rightPadding: highlight.margins.right + bottomPadding: highlight.margins.bottom + spacing: units.smallSpacing + hoverEnabled: true + + contentItem: Label { + leftPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + + text: control.text + font: control.font + color: theme.textColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + indicator: CheckIndicator { + x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + visible: control.checkable + checkState: control.checked ? Qt.Checked : 0 + } + + background: Item { + implicitWidth: units.gridUnit * 8 + + PlasmaCore.FrameSvgItem { + id: highlight + imagePath: "widgets/viewitem" + prefix: "hover" + colorGroup: PlasmaCore.ColorScope.colorGroup + anchors.fill: parent + opacity: control.hovered && !control.pressed ? 1 : 0 + Behavior on opacity { + NumberAnimation { + duration: units.longDuration + } + } + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/Popup.qml b/src/declarativeimports/plasmacomponents3/Popup.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Popup.qml @@ -0,0 +1,66 @@ +/* + * 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 2.1 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Popup { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentWidth > 0 ? contentHeight + topPadding + bottomPadding : 0) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + leftPadding: background.margins.left + topPadding: background.margins.top + rightPadding: background.margins.right + bottomPadding: background.margins.bottom + + enter: Transition { + NumberAnimation { + property: "opacity" + from: 0 + to: 1 + easing.type: Easing.InOutQuad + duration: 250 + } + } + + exit: Transition { + NumberAnimation { + property: "opacity" + from: 1 + to: 0 + easing.type: Easing.InOutQuad + duration: 250 + } + } + + contentItem: Item { } + + background: PlasmaCore.FrameSvgItem { + implicitWidth: units.gridUnit * 12 + imagePath: "widgets/background" + } +} diff --git a/src/declarativeimports/plasmacomponents3/ProgressBar.qml b/src/declarativeimports/plasmacomponents3/ProgressBar.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ProgressBar.qml @@ -0,0 +1,79 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.ProgressBar { + id: control + + implicitWidth: units.gridUnit * 8 + implicitHeight: background.implicitHeight + + hoverEnabled: true + + contentItem: Item { + PlasmaCore.FrameSvgItem { + id: indicator + height: parent.height + width: control.indeterminate ? units.gridUnit * 2 : parent.width * control.visualPosition + imagePath: "widgets/bar_meter_horizontal" + prefix: "bar-active" + colorGroup: PlasmaCore.ColorScope.colorGroup + } + SequentialAnimation { + id: anim + loops: Animation.Infinite + + running: control.indeterminate && control.visible + + PropertyAnimation { + target: indicator + property: "x" + duration: 800 + to: control.width - indicator.width + onToChanged: { + //the animation won't update the boundaries automatically + if (anim.running) { + anim.restart(); + } + } + } + PropertyAnimation { + target: indicator + property: "x" + duration: 800 + to: 0 + } + } + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/bar_meter_horizontal" + prefix: "bar-inactive" + colorGroup: PlasmaCore.ColorScope.colorGroup + onRepaintNeeded: { + implicitHeight = barSvg.elementSize("hint-bar-size").height + if (implicitHeight == 0) { + implicitHeight = barSvg.elementSize("bar-inactive-top").height + barSvg.elementSize("bar-inactive-bottom").height + } + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/RadioButton.qml b/src/declarativeimports/plasmacomponents3/RadioButton.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/RadioButton.qml @@ -0,0 +1,60 @@ +/* + * 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 2.0 as T +import QtQuick.Controls 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +T.RadioButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: units.gridUnit * 1.6 + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 1 + spacing: Math.round(units.gridUnit / 8) + + hoverEnabled: true + + indicator: RadioIndicator { + LayoutMirroring.enabled: control.mirrored + LayoutMirroring.childrenInherit: true + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + } + control: control + } + + contentItem: Label { + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + opacity: control.enabled ? 1 : 0.6 + text: control.text + font: control.font + color: PlasmaCore.ColorScope.textColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } +} diff --git a/src/declarativeimports/plasmacomponents3/RadioDelegate.qml b/src/declarativeimports/plasmacomponents3/RadioDelegate.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/RadioDelegate.qml @@ -0,0 +1,60 @@ +/* + * 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.5 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" + +T.RadioDelegate { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding + hoverEnabled: true + + topPadding: background.margins.top + bottomPadding: background.margins.bottom + leftPadding: background.margins.left + rightPadding: background.margins.right + spacing: units.smallSpacing + + contentItem: Label { + leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + + text: control.text + font: control.font + color: theme.viewTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + indicator: RadioIndicator { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + control: control + } + + background: DefaultListItemBackground {} +} diff --git a/src/declarativeimports/plasmacomponents3/RadioIndicator.qml b/src/declarativeimports/plasmacomponents3/RadioIndicator.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/RadioIndicator.qml @@ -0,0 +1,59 @@ +/* + * 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 org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +PlasmaCore.SvgItem { + property Item control + svg: PlasmaCore.Svg { + id: buttonSvg + imagePath: "widgets/actionbutton" + } + elementId: "normal" + opacity: control.enabled ? 1 : 0.6 + + implicitWidth: implicitHeight + implicitHeight: units.gridUnit + + PlasmaCore.SvgItem { + id: checkmark + svg: PlasmaCore.Svg { + id: checkmarkSvg + imagePath: "widgets/checkmarks" + } + elementId: "radiobutton" + opacity: control.checked ? 1 : 0 + anchors { + fill: parent + } + Behavior on opacity { + NumberAnimation { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + Private.RoundShadow { + anchors.fill: parent + z: -1 + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") + } +} diff --git a/src/declarativeimports/plasmacomponents3/RangeSlider.qml b/src/declarativeimports/plasmacomponents3/RangeSlider.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/RangeSlider.qml @@ -0,0 +1,108 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +T.RangeSlider { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + Math.max(first.handle ? first.handle.implicitWidth : 0, + second.handle ? second.handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(first.handle ? first.handle.implicitHeight : 0, + second.handle ? second.handle.implicitHeight : 0) + topPadding + bottomPadding) + + padding: units.gridUnit + + PlasmaCore.Svg { + id: grooveSvg + imagePath: "widgets/slider" + colorGroup: PlasmaCore.ColorScope.colorGroup + + } + first.handle: Item { + property bool horizontal: control.orientation === Qt.Horizontal + x: control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) + + width: firstHandle.naturalSize.width + height: firstHandle.naturalSize.height + Private.RoundShadow { + anchors.fill: parent + imagePath: "widgets/slider" + focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus" + hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover" + shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow" + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") + } + PlasmaCore.SvgItem { + id: firstHandle + anchors.fill: parent + svg: grooveSvg + elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle" + } + } + + second.handle: Item { + property bool horizontal: control.orientation === Qt.Horizontal + x: control.leftPadding + (horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height)) + + width: secondHandle.naturalSize.width + height: secondHandle.naturalSize.height + Private.RoundShadow { + anchors.fill: parent + imagePath: "widgets/slider" + focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus" + hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover" + shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow" + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") + } + PlasmaCore.SvgItem { + id: secondHandle + anchors.fill: parent + svg: grooveSvg + elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle" + } + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/slider" + prefix: "groove" + readonly property bool horizontal: control.orientation === Qt.Horizontal + implicitWidth: horizontal ? units.gridUnit * 8 : margins.left + margins.right + implicitHeight: horizontal ? margins.top + margins.bottom : units.gridUnit * 8 + width: horizontal ? control.availableWidth : implicitWidth + height: horizontal ? implicitHeight : control.availableHeight + anchors.centerIn: parent + + PlasmaCore.FrameSvgItem { + imagePath: "widgets/slider" + prefix: "groove-highlight" + x: parent.horizontal ? control.first.position * parent.width : 0 + y: parent.horizontal ? 0 : control.second.visualPosition * parent.height + width: parent.horizontal ? control.second.position * parent.width - control.first.position * parent.width : parent.width + height: parent.horizontal ? parent.height : control.second.position * parent.height - control.first.position * parent.height + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/ScrollBar.qml b/src/declarativeimports/plasmacomponents3/ScrollBar.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ScrollBar.qml @@ -0,0 +1,67 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + + +T.ScrollBar { + id: control + + implicitWidth: background.implicitWidth + implicitHeight: background.implicitHeight + + hoverEnabled: true + + visible: control.size < 1.0 + + background: PlasmaCore.FrameSvgItem { + imagePath:"widgets/scrollbar" + implicitWidth: scrollbarSvg.elementSize("hint-scrollbar-size").width + implicitHeight: implicitWidth + colorGroup: PlasmaCore.ColorScope.colorGroup + + prefix: control.horizontal ? "background-horizontal" : "background-vertical" + opacity: control.hovered ? 1 : 0 + Behavior on opacity { + OpacityAnimator { + duration: 250 + } + } + } + + contentItem: PlasmaCore.FrameSvgItem { + imagePath:"widgets/scrollbar" + implicitWidth: scrollbarSvg.elementSize("hint-scrollbar-size").width + implicitHeight: implicitWidth + colorGroup: PlasmaCore.ColorScope.colorGroup + + prefix: control.hovered ? "mouseover-slider" : "slider" + } + + PlasmaCore.Svg { + id: scrollbarSvg + imagePath: "widgets/scrollbar" + //TODO: support arrows? + property bool arrowPresent: scrollbarSvg.hasElement("arrow-up") + //new theme may be different + onRepaintNeeded: arrowPresent = scrollbarSvg.hasElement("arrow-up") + } +} diff --git a/src/declarativeimports/plasmacomponents3/Slider.qml b/src/declarativeimports/plasmacomponents3/Slider.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Slider.qml @@ -0,0 +1,100 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +T.Slider { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + Math.max(handle ? handle.implicitWidth : 0, + handle ? handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(handle ? handle.implicitHeight : 0, + handle ? handle.implicitHeight : 0) + topPadding + bottomPadding) + + padding: units.gridUnit + snapMode: T.Slider.SnapOnRelease + + PlasmaCore.Svg { + id: grooveSvg + imagePath: "widgets/slider" + colorGroup: PlasmaCore.ColorScope.colorGroup + + } + handle: Item { + property bool horizontal: control.orientation === Qt.Horizontal + x: control.leftPadding + (horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) + + width: firstHandle.naturalSize.width + height: firstHandle.naturalSize.height + Private.RoundShadow { + anchors.fill: parent + imagePath: "widgets/slider" + focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus" + hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover" + shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow" + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") + } + PlasmaCore.SvgItem { + id: firstHandle + anchors.fill: parent + svg: grooveSvg + elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle" + } + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/slider" + prefix: "groove" + readonly property bool horizontal: control.orientation === Qt.Horizontal + implicitWidth: horizontal ? units.gridUnit * 8 : margins.left + margins.right + implicitHeight: horizontal ? margins.top + margins.bottom : units.gridUnit * 8 + width: horizontal ? control.availableWidth : implicitWidth + height: horizontal ? implicitHeight : control.availableHeight + anchors.centerIn: parent + + PlasmaCore.FrameSvgItem { + imagePath: "widgets/slider" + prefix: "groove-highlight" + x: parent.horizontal ? 0 : (parent.width - width) / 2 + y: parent.horizontal ? (parent.height - height) / 2 : control.visualPosition * parent.height + width: parent.horizontal ? control.position * parent.width : parent.width + height: parent.horizontal ? parent.height : control.position * parent.height + } + + Repeater { + id: repeater + model: control.stepSize > 0 ? 1 + (control.to - control.from) / control.stepSize : 0 + anchors.fill: parent + + Rectangle { + color: PlasmaCore.ColorScope.textColor + width: background.horizontal ? units.devicePixelRatio : units.gridUnit/2 + height: background.horizontal ? units.gridUnit/2 : units.devicePixelRatio + y: background.horizontal ? background.height : handle.height / 2 + index * ((repeater.height - handle.height) / (repeater.count > 1 ? repeater.count - 1 : 1)) + x: background.horizontal ? handle.width / 2 + index * ((repeater.width - handle.width) / (repeater.count > 1 ? repeater.count - 1 : 1)) : background.width + } + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/SpinBox.qml b/src/declarativeimports/plasmacomponents3/SpinBox.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/SpinBox.qml @@ -0,0 +1,89 @@ + + +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +T.SpinBox { + id: control + + implicitWidth: Math.max(units.gridUnit * 6, contentItem.implicitWidth + 2 * padding + up.indicator.implicitWidth + down.indicator.implicitWidth) + implicitHeight: units.gridUnit * 1.6 + + padding: 6 + leftPadding: padding + height + rightPadding: padding + height + + validator: IntValidator { + locale: control.locale.name + bottom: Math.min(control.from, control.to) + top: Math.max(control.from, control.to) + } + + contentItem: TextInput { + text: control.textFromValue(control.value, control.locale) + opacity: control.enabled ? 1 : 0.6 + + font: control.font + color: theme.viewTextColor + selectionColor: theme.highlightColor + selectedTextColor: theme.selectedTextColor + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + + readOnly: !control.editable + validator: control.validator + inputMethodHints: Qt.ImhFormattedNumbersOnly + } + + up.indicator: Item { + x: control.mirrored ? 0 : parent.width - width + implicitHeight: parent.height + implicitWidth: implicitHeight + PlasmaCore.FrameSvgItem { + anchors { + fill: parent + margins: base.margins.right + } + imagePath: "widgets/button" + prefix: up.pressed ? "pressed" : "normal" + Label { + anchors.centerIn: parent + text: "+" + } + } + } + + down.indicator:Item { + x: control.mirrored ? parent.width - width : 0 + implicitHeight: parent.height + implicitWidth: implicitHeight + PlasmaCore.FrameSvgItem { + anchors { + fill: parent + margins: base.margins.left + } + imagePath: "widgets/button" + prefix: down.pressed ? "pressed" : "normal" + Label { + anchors.centerIn: parent + text: "-" + } + } + } + + background: Item { + Private.TextFieldFocus { + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") + anchors.fill: parent + } + PlasmaCore.FrameSvgItem { + id: base + anchors.fill: parent + imagePath: "widgets/lineedit" + prefix: "base" + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/Switch.qml b/src/declarativeimports/plasmacomponents3/Switch.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/Switch.qml @@ -0,0 +1,60 @@ +/* + * 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 2.0 as T +import QtQuick.Controls 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +T.Switch { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: units.gridUnit * 1.6 + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 1 + spacing: Math.round(units.gridUnit / 8) + + hoverEnabled: true + + indicator: SwitchIndicator { + LayoutMirroring.enabled: control.mirrored + LayoutMirroring.childrenInherit: true + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + } + control: control + } + + contentItem: Label { + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + opacity: control.enabled ? 1 : 0.6 + text: control.text + font: control.font + color: PlasmaCore.ColorScope.textColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } +} diff --git a/src/declarativeimports/plasmacomponents3/SwitchDelegate.qml b/src/declarativeimports/plasmacomponents3/SwitchDelegate.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/SwitchDelegate.qml @@ -0,0 +1,60 @@ +/* + * 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.5 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" + +T.SwitchDelegate { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding + hoverEnabled: true + + topPadding: background.margins.top + bottomPadding: background.margins.bottom + leftPadding: background.margins.left + rightPadding: background.margins.right + spacing: units.smallSpacing + + contentItem: Label { + leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0 + + text: control.text + font: control.font + color: theme.viewTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + indicator: SwitchIndicator { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + control: control + } + + background: DefaultListItemBackground {} +} diff --git a/src/declarativeimports/plasmacomponents3/SwitchIndicator.qml b/src/declarativeimports/plasmacomponents3/SwitchIndicator.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/SwitchIndicator.qml @@ -0,0 +1,81 @@ +/* + * 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 org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +Item { + property Item control + implicitWidth: Math.round(units.gridUnit * 1.5) + implicitHeight : units.gridUnit + + opacity: control.enabled ? 1 : 0.6 + + PlasmaCore.FrameSvgItem { + anchors { + left: parent.left + right: parent.right + verticalCenter: parent.verticalCenter + } + imagePath: "widgets/bar_meter_horizontal" + prefix: "bar-inactive" + } + PlasmaCore.FrameSvgItem { + anchors { + left: parent.left + right: parent.right + verticalCenter: parent.verticalCenter + } + imagePath: "widgets/bar_meter_horizontal" + prefix: "bar-active" + opacity: control.checked ? 1 : 0 + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + PlasmaCore.SvgItem { + x: control.mirrored ? (control.checked ? 0 : parent.width - width) : (control.checked ? parent.width - width : 0) + anchors.verticalCenter: parent.verticalCenter + svg: PlasmaCore.Svg { + id: buttonSvg + imagePath: "widgets/actionbutton" + } + elementId: "normal" + + implicitWidth: implicitHeight + implicitHeight: units.gridUnit + + Private.RoundShadow { + anchors.fill: parent + z: -1 + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") + } + Behavior on x { + XAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } +} + diff --git a/src/declarativeimports/plasmacomponents3/TabBar.qml b/src/declarativeimports/plasmacomponents3/TabBar.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/TabBar.qml @@ -0,0 +1,59 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.TabBar { + id: control + + implicitWidth: contentItem.implicitWidth + implicitHeight: contentItem.implicitHeight + + spacing: 0 + + contentItem: ListView { + implicitWidth: control.contentModel.get(0).implicitWidth * count + implicitHeight: control.contentModel.get(0).height + + model: control.contentModel + currentIndex: control.currentIndex + + spacing: 0 + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + flickableDirection: Flickable.AutoFlickIfNeeded + snapMode: ListView.SnapToItem + + highlightMoveDuration: units.longDuration + highlightRangeMode: ListView.ApplyRange + preferredHighlightBegin: 40 + preferredHighlightEnd: width - 40 + highlight: PlasmaCore.FrameSvgItem { + imagePath: "widgets/tabbar" + prefix: control.position == T.TabBar.Header ? "north-active-tab" : "south-active-tab" + colorGroup: PlasmaCore.ColorScope.colorGroup + } + } + + + + background: Item {} +} diff --git a/src/declarativeimports/plasmacomponents3/TabButton.qml b/src/declarativeimports/plasmacomponents3/TabButton.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/TabButton.qml @@ -0,0 +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 2.0 +import QtQml.Models 2.1 +import QtQuick.Templates 2.0 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 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + background: Item {} +} diff --git a/src/declarativeimports/plasmacomponents3/TextArea.qml b/src/declarativeimports/plasmacomponents3/TextArea.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/TextArea.qml @@ -0,0 +1,74 @@ +/* + * 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 2.0 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +T.TextArea { + id: control + + implicitWidth: Math.max(contentWidth + leftPadding + rightPadding, + background ? background.implicitWidth : 0, + placeholder.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(contentHeight + topPadding + bottomPadding, + background ? background.implicitHeight : 0, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: 6 + + color: theme.viewTextColor + selectionColor: theme.highlightColor + selectedTextColor: theme.highlightedTextColor + opacity: control.enabled ? 1 : 0.6 + wrapMode: Text.WordWrap + verticalAlignment: TextEdit.AlignTop + renderType: Text.NativeRendering + + Label { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + text: control.placeholderText + font: control.font + color: theme.viewTextColor + horizontalAlignment: control.horizontalAlignment + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + } + + background: Item { + Private.TextFieldFocus { + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") + anchors.fill: parent + } + PlasmaCore.FrameSvgItem { + id: base + anchors.fill: parent + imagePath: "widgets/lineedit" + prefix: "base" + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/TextField.qml b/src/declarativeimports/plasmacomponents3/TextField.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/TextField.qml @@ -0,0 +1,72 @@ +/* + * 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 2.0 +import QtQuick.Templates 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + + +T.TextField { + id: control + + implicitWidth: Math.max(units.gridUnit * 8, + placeholderText ? placeholder.implicitWidth + leftPadding + rightPadding : 0) + || contentWidth + leftPadding + rightPadding + implicitHeight: units.gridUnit * 1.6 + + padding: 6 + + color: theme.viewTextColor + selectionColor: theme.highlightColor + selectedTextColor: theme.highlightedTextColor + verticalAlignment: TextInput.AlignVCenter + opacity: control.enabled ? 1 : 0.6 + renderType: Text.NativeRendering + + Label { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + text: control.placeholderText + font: control.font + color: theme.viewTextColor + horizontalAlignment: control.horizontalAlignment + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + } + + background: Item { + Private.TextFieldFocus { + state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden") + anchors.fill: parent + } + PlasmaCore.FrameSvgItem { + id: base + anchors.fill: parent + imagePath: "widgets/lineedit" + prefix: "base" + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/ToolBar.qml b/src/declarativeimports/plasmacomponents3/ToolBar.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ToolBar.qml @@ -0,0 +1,40 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.ToolBar { + id: control + + implicitWidth: contentWidth + leftPadding + rightPadding + implicitHeight: contentHeight + topPadding + bottomPadding + + contentWidth: contentChildren[0].implicitWidth + contentHeight: contentChildren[0].implicitHeight + + contentItem: Item { } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/toolbar" + colorGroup: PlasmaCore.ColorScope.colorGroup + enabledBorders: control.position == T.ToolBar.Header ? PlasmaCore.FrameSvgItem.BottomBorder : PlasmaCore.FrameSvgItem.TopBorder + } +} diff --git a/src/declarativeimports/plasmacomponents3/ToolButton.qml b/src/declarativeimports/plasmacomponents3/ToolButton.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ToolButton.qml @@ -0,0 +1,96 @@ +/* + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore +import "private" as Private + +T.ToolButton { + id: control + + implicitWidth: Math.max(background.implicitWidth, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) + + leftPadding: surfaceNormal.margins.left + topPadding: surfaceNormal.margins.top + rightPadding: surfaceNormal.margins.right + bottomPadding: surfaceNormal.margins.bottom + + hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? + + flat: true + + contentItem: Label { + text: control.text + font: control.font + opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 + color: theme.buttonTextColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Item { + //retrocompatibility with old controls + implicitWidth: units.gridUnit * 6 + implicitHeight: units.gridUnit * 1.6 + Private.ButtonShadow { + anchors.fill: parent + visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) + state: { + if (control.pressed) { + return "hidden" + } else if (control.hovered) { + return "hover" + } else if (control.activeFocus) { + return "focus" + } else { + return "shadow" + } + } + } + PlasmaCore.FrameSvgItem { + id: surfaceNormal + anchors.fill: parent + imagePath: "widgets/button" + prefix: "normal" + opacity: (!control.flat || control.hovered) && (!control.pressed || !control.checked) ? 1 : 0 + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + PlasmaCore.FrameSvgItem { + anchors.fill: parent + imagePath: "widgets/button" + prefix: "pressed" + opacity: control.checked || control.pressed ? 1 : 0 + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + } + } +} diff --git a/src/declarativeimports/plasmacomponents3/ToolTip.qml b/src/declarativeimports/plasmacomponents3/ToolTip.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ToolTip.qml @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Marco Martin + * Copyright (C) 2016 The Qt Company Ltd. + * + * 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 2.0 as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.ToolTip { + id: control + + x: parent ? (parent.width - implicitWidth) / 2 : 0 + y: -implicitHeight - 3 + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding + + margins: units.gridUnit + leftPadding: background.margins.left + topPadding: background.margins.top + rightPadding: background.margins.right + bottomPadding: background.margins.bottom + + closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent | T.Popup.CloseOnReleaseOutsideParent + + contentItem: Label { + text: control.text + font: control.font + color: PlasmaCore.ColorScope.textColor + } + + background: PlasmaCore.FrameSvgItem { + imagePath: "widgets/background" + } +} diff --git a/src/declarativeimports/plasmacomponents3/private/ButtonShadow.qml b/src/declarativeimports/plasmacomponents3/private/ButtonShadow.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/private/ButtonShadow.qml @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2011 by Daker Fernandes Pinheiro + * 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. + */ + +/**Documented API +Inherits: + Item + +Imports: + QtQuick 2.1 + org.kde.plasma.core + +Description: +TODO i need more info here + + +Properties: +**/ + +import QtQuick 2.1 +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: main + state: parent.state + //used to tell apart this implementation with the touch components one + property bool hasOverState: true + property alias enabledBorders: shadow.enabledBorders + + PlasmaCore.FrameSvgItem { + id: hover + + anchors { + fill: parent + leftMargin: -margins.left + topMargin: -margins.top + rightMargin: -margins.right + bottomMargin: -margins.bottom + } + opacity: 0 + imagePath: "widgets/button" + prefix: "hover" + } + + PlasmaCore.FrameSvgItem { + id: shadow + + anchors { + fill: parent + leftMargin: -margins.left + topMargin: -margins.top + rightMargin: -margins.right + bottomMargin: -margins.bottom + } + imagePath: "widgets/button" + prefix: "shadow" + } + + states: [ + State { + name: "shadow" + PropertyChanges { + target: shadow + opacity: 1 + } + PropertyChanges { + target: hover + opacity: 0 + prefix: "hover" + } + }, + State { + name: "hover" + PropertyChanges { + target: shadow + opacity: 0 + } + PropertyChanges { + target: hover + opacity: 1 + prefix: "hover" + } + }, + State { + name: "focus" + PropertyChanges { + target: shadow + opacity: 0 + } + PropertyChanges { + target: hover + opacity: 1 + prefix: "focus" + } + }, + State { + name: "hidden" + PropertyChanges { + target: shadow + opacity: 0 + } + PropertyChanges { + target: hover + opacity: 0 + prefix: "hover" + } + } + ] + + transitions: [ + Transition { + PropertyAnimation { + properties: "opacity" + duration: units.longDuration + easing.type: Easing.OutQuad + } + } + ] +} diff --git a/src/declarativeimports/plasmacomponents3/private/DefaultListItemBackground.qml b/src/declarativeimports/plasmacomponents3/private/DefaultListItemBackground.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/private/DefaultListItemBackground.qml @@ -0,0 +1,56 @@ +/* + * 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.1 +//for Settings +import QtQuick.Controls 1.0 as Controls +import QtQuick.Controls.Private 1.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +PlasmaCore.FrameSvgItem { + id: background + + property bool separatorVisible: false + imagePath: "widgets/listitem" + prefix: control.highlighted || control.pressed ? "pressed" : "normal" + + visible: control.ListView.view ? control.ListView.view.highlight === null : true + + PlasmaCore.FrameSvgItem { + imagePath: "widgets/listitem" + visible: !Settings.isMobile + prefix: "hover" + anchors.fill: parent + opacity: control.hovered && !control.pressed ? 1 : 0 + Behavior on opacity { NumberAnimation { duration: units.longDuration } } + } + + PlasmaCore.SvgItem { + svg: PlasmaCore.Svg {imagePath: "widgets/listitem"} + elementId: "separator" + anchors { + left: parent.left + right: parent.right + top: parent.top + } + height: naturalSize.height + visible: separatorVisible && (listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)) + } +} + diff --git a/src/declarativeimports/plasmacomponents3/private/RoundShadow.qml b/src/declarativeimports/plasmacomponents3/private/RoundShadow.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/private/RoundShadow.qml @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2011 by Daker Fernandes Pinheiro + * 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. + */ + +/**Documented API +Inherits: + Item + +Imports: + QtQuick 2.1 + org.kde.plasma.core + +Description: + It is a simple Radio button which is using the plasma theme. + TODO Do we need more info? + +Properties: + TODO needs more info?? +**/ + +import QtQuick 2.1 +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: main + state: parent.state + property alias imagePath: shadowSvg.imagePath + property string hoverElement: "hover" + property string focusElement: "focus" + property alias shadowElement: shadow.elementId + + //used to tell apart this implementation with the touch components one + property bool hasOverState: true + + PlasmaCore.Svg { + id: shadowSvg + imagePath: "widgets/actionbutton" + } + + PlasmaCore.SvgItem { + id: hover + svg: shadowSvg + elementId: "hover" + + anchors.fill: parent + + opacity: 0 + } + + PlasmaCore.SvgItem { + id: shadow + svg: shadowSvg + elementId: "shadow" + + anchors.fill: parent + } + + states: [ + State { + name: "shadow" + PropertyChanges { + target: shadow + opacity: 1 + } + PropertyChanges { + target: hover + opacity: 0 + elementId: hoverElement + } + }, + State { + name: "hover" + PropertyChanges { + target: shadow + opacity: 0 + } + PropertyChanges { + target: hover + opacity: 1 + elementId: hoverElement + } + }, + State { + name: "focus" + PropertyChanges { + target: shadow + opacity: 0 + } + PropertyChanges { + target: hover + opacity: 1 + elementId: focusElement + } + }, + State { + name: "hidden" + PropertyChanges { + target: shadow + opacity: 0 + } + PropertyChanges { + target: hover + opacity: 0 + elementId: hoverElement + } + } + ] + + transitions: [ + Transition { + PropertyAnimation { + properties: "opacity" + duration: units.longDuration + easing.type: Easing.OutQuad + } + } + ] +} diff --git a/src/declarativeimports/plasmacomponents3/private/TextFieldFocus.qml b/src/declarativeimports/plasmacomponents3/private/TextFieldFocus.qml new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/private/TextFieldFocus.qml @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2011 by Daker Fernandes Pinheiro + * 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 org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: main + state: parent.state + + PlasmaCore.Svg { + id: lineEditSvg + imagePath: "widgets/lineedit" + onRepaintNeeded: { + if (lineEditSvg.hasElement("hint-focus-over-base")) { + main.z = 800 + } else { + main.z = 0 + } + } + Component.onCompleted: { + if (lineEditSvg.hasElement("hint-focus-over-base")) { + main.z = 800 + } else { + main.z = 0 + } + } + } + + PlasmaCore.FrameSvgItem { + id: hover + + anchors { + fill: parent + leftMargin: -margins.left + topMargin: -margins.top + rightMargin: -margins.right + bottomMargin: -margins.bottom + } + opacity: 0 + imagePath: "widgets/lineedit" + prefix: "hover" + } + + states: [ + State { + name: "hover" + PropertyChanges { + target: hover + opacity: 1 + prefix: "hover" + } + }, + State { + name: "focus" + PropertyChanges { + target: hover + opacity: 1 + prefix: "focus" + } + }, + State { + name: "hidden" + PropertyChanges { + target: hover + opacity: 0 + prefix: "hover" + } + } + ] + + transitions: [ + Transition { + PropertyAnimation { + properties: "opacity" + duration: units.longDuration + easing.type: Easing.OutQuad + } + } + ] +} diff --git a/src/declarativeimports/plasmacomponents3/qmldir b/src/declarativeimports/plasmacomponents3/qmldir new file mode 100644 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/qmldir @@ -0,0 +1,34 @@ +module org.kde.plasma.components + +BusyIndicator 3.0 BusyIndicator.qml +Button 3.0 Button.qml +CheckBox 3.0 CheckBox.qml +CheckDelegate 3.0 CheckDelegate.qml +ComboBox 3.0 ComboBox.qml +Container 3.0 Container.qml +Control 3.0 Control.qml +Dial 3.0 Dial.qml +Drawer 3.0 Drawer.qml +Frame 3.0 Frame.qml +GroupBox 3.0 GroupBox.qml +ItemDelegate 3.0 ItemDelegate.qml +Label 3.0 Label.qml +MenuItem 3.0 MenuItem.qml +Menu 3.0 Menu.qml +Popup 3.0 Popup.qml +ProgressBar 3.0 ProgressBar.qml +RadioButton 3.0 RadioButton.qml +RadioDelegate 3.0 RadioDelegate.qml +RangeSlider 3.0 RangeSlider.qml +ScrollBar 3.0 ScrollBar.qml +Slider 3.0 Slider.qml +SpinBox 3.0 SpinBox.qml +SwitchDelegate 3.0 SwitchDelegate.qml +Switch 3.0 Switch.qml +TabBar 3.0 TabBar.qml +TabButton 3.0 TabButton.qml +TextArea 3.0 TextArea.qml +TextField 3.0 TextField.qml +ToolBar 3.0 ToolBar.qml +ToolButton 3.0 ToolButton.qml +ToolTip 3.0 ToolTip.qml