1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-21 10:50:30 +03:00

fork PlasmaComponents3.ComboBox to adjust for Latte

This commit is contained in:
Michail Vourlakos 2019-03-25 23:08:28 +02:00
parent 08ec690805
commit 03001f4280
14 changed files with 971 additions and 65 deletions

View File

@ -0,0 +1,293 @@
/*
* Copyright 2016 Marco Martin <mart@kde.org>
*
* 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.7
import QtQuick.Window 2.2
import QtQuick.Templates 2.2 as T
import QtQuick.Controls 2.2 as Controls
import QtGraphicalEffects 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.5 as Kirigami
import "private" as Private
T.ComboBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding) + indicator.implicitWidth + rightPadding
implicitHeight: units.gridUnit * 1.6
baselineOffset: contentItem.y + contentItem.baselineOffset
hoverEnabled: true
topPadding: surfaceNormal.margins.top
leftPadding: surfaceNormal.margins.left
rightPadding: surfaceNormal.margins.right + units.gridUnit * 2
bottomPadding: surfaceNormal.margins.bottom
wheelEnabled: false
delegate: ItemDelegate {
width: control.popup.width
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
highlighted: mouseArea.pressed ? listView.currentIndex == index : control.currentIndex == index
property bool separatorVisible: false
}
indicator: PlasmaCore.SvgItem {
implicitWidth: units.iconSizes.small
implicitHeight: implicitWidth
anchors {
right: parent.right
rightMargin: surfaceNormal.margins.right
verticalCenter: parent.verticalCenter
}
svg: PlasmaCore.Svg {
imagePath: "widgets/arrows"
colorGroup: PlasmaCore.Theme.ButtonColorGroup
}
elementId: "down-arrow"
}
// contentItem: Label {
// text: control.displayText
// font: control.font
// color: theme.buttonTextColor
// horizontalAlignment: Text.AlignLeft
// verticalAlignment: Text.AlignVCenter
// elide: Text.ElideRight
// }
contentItem: MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
preventStealing: true
property int indexUnderMouse: -1
onWheel: {
if (!control.wheelEnabled) {
return;
}
if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1);
} else {
control.currentIndex = Math.max(control.currentIndex - 1, 0);
}
control.activated(control.currentIndex);
}
onPressed: {
indexUnderMouse = -1;
listView.currentIndex = control.highlightedIndex
control.down = true;
control.pressed = true;
control.popup.visible = !control.popup.visible;
}
onReleased: {
if (!containsMouse) {
control.down = false;
control.pressed = false;
control.popup.visible = false;
}
if (indexUnderMouse > -1) {
control.currentIndex = indexUnderMouse;
}
}
onCanceled: {
control.down = false;
control.pressed = false;
}
onPositionChanged: {
var pos = listView.mapFromItem(this, mouse.x, mouse.y);
indexUnderMouse = listView.indexAt(pos.x, pos.y);
listView.currentIndex = indexUnderMouse;
control.activated(indexUnderMouse);
}
Connections {
target: popup
onClosed: {
control.down = false;
control.pressed = false;
}
}
T.TextField {
id: textField
padding: 0
anchors {
fill:parent
leftMargin: control.leftPadding
rightMargin: control.rightPadding
topMargin: control.topPadding
bottomMargin: control.bottomPadding
}
text: control.editable ? control.editText : control.displayText
enabled: control.editable
autoScroll: control.editable
readOnly: control.down || !control.hasOwnProperty("editable") || !control.editable
inputMethodHints: control.inputMethodHints
validator: control.validator
// Work around Qt bug where NativeRendering breaks for non-integer scale factors
// https://bugreports.qt.io/browse/QTBUG-67007
renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering
color: theme.textColor// control.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
selectionColor: Kirigami.Theme.highlightColor
selectedTextColor: Kirigami.Theme.highlightedTextColor
selectByMouse: !Kirigami.Settings.tabletMode
cursorDelegate: Kirigami.Settings.tabletMode ? mobileCursor : undefined
font: control.font
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
opacity: 1//control.enabled ? 1 : 0.3
onFocusChanged: {
if (focus) {
Private.MobileTextActionsToolBar.controlRoot = textField;
}
}
onPressAndHold: {
if (!Kirigami.Settings.tabletMode) {
return;
}
forceActiveFocus();
cursorPosition = positionAt(event.x, event.y);
selectWord();
}
}
}
Component {
id: mobileCursor
Private.MobileCursor {
target: textField
}
}
Private.MobileCursor {
target: textField
selectionStartHandle: true
property var rect: textField.positionToRectangle(textField.selectionStart)
//FIXME: this magic values seem to be always valid, for every font,every dpi, every scaling
x: rect.x + 5
y: rect.y + 6
}
background: PlasmaCore.FrameSvgItem {
id: surfaceNormal
//retrocompatibility with old controls
implicitWidth: units.gridUnit * 6
anchors.fill: parent
readonly property bool editable: control.hasOwnProperty("editable") && control.editable
imagePath: editable ? "widgets/lineedit" : "widgets/button"
prefix: editable
? "base"
: (control.pressed ? "pressed" : "normal")
Private.TextFieldFocus {
visible: parent.editable
z: -1
state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "hidden")
anchors.fill: parent
}
Private.ButtonShadow {
z: -1
visible: !parent.editable
anchors.fill: parent
state: {
if (control.pressed) {
return "hidden"
} else if (control.hovered) {
return "hover"
} else if (control.activeFocus) {
return "focus"
} else {
return "shadow"
}
}
}
MouseArea {
anchors {
fill: parent
leftMargin: control.leftPadding
rightMargin: control.rightPadding
}
acceptedButtons: Qt.NoButton
onWheel: {
if (!control.wheelEnabled) {
return;
}
if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1);
} else {
control.currentIndex = Math.max(control.currentIndex - 1, 0);
}
control.activated(control.currentIndex);
}
}
}
popup: T.Popup {
x: control.mirrored ? control.width - width : 0
y: control.height
width: Math.max(control.width, 150)
implicitHeight: contentItem.implicitHeight
topMargin: 6
bottomMargin: 6
contentItem: ListView {
id: listView
clip: true
implicitHeight: contentHeight
model: control.popup.visible ? control.delegateModel : null
currentIndex: control.highlightedIndex
highlightRangeMode: ListView.ApplyRange
highlightMoveDuration: 0
// HACK: When the ComboBox is not inside a top-level Window, it's Popup does not inherit
// the LayoutMirroring options. This is a workaround to fix this by enforcing
// the LayoutMirroring options properly.
// QTBUG: https://bugreports.qt.io/browse/QTBUG-66446
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
T.ScrollBar.vertical: Controls.ScrollBar { }
}
background: Rectangle {
anchors {
fill: parent
margins: -1
}
radius: 2
color: theme.viewBackgroundColor
border.color: Qt.rgba(theme.textColor.r, theme.textColor.g, theme.textColor.b, 0.3)
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
radius: 4
samples: 8
horizontalOffset: 2
verticalOffset: 2
color: Qt.rgba(0, 0, 0, 0.3)
}
}
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.latte 0.2 as Latte
import org.kde.latte.components 1.0 as LatteComponents
PlasmaComponents.Button {
id: root
text: " "
readonly property Item comboBox: mainComboBox
readonly property Item button: mainButton
property bool buttonEnabled: true
property string buttonText:""
property string buttonIconSource:""
property string buttonToolTip: ""
property bool comboBoxEnabled: true
LatteComponents.ComboBox {
id: mainComboBox
anchors.fill: parent
enabled: comboBoxEnabled
}
//overlayed button
PlasmaComponents.Button {
id: mainButton
anchors.left: Qt.application.layoutDirection === Qt.RightToLeft ? undefined : parent.left
anchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? parent.right : undefined
LayoutMirroring.enabled: false
enabled: buttonEnabled
width: parent.width - units.iconSizes.medium + 2*units.smallSpacing
height: mainComboBox.height
text: buttonText
iconSource: buttonIconSource
tooltip: buttonToolTip
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright 2016 Marco Martin <mart@kde.org>
*
* 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.2 as T
import org.kde.plasma.core 2.0 as PlasmaCore
import "private" as Private
T.CheckDelegate {
id: control
implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
implicitHeight: Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
hoverEnabled: true
topPadding: margin
bottomPadding: margin
leftPadding: margin
rightPadding: margin
spacing: units.smallSpacing
readonly property int margin: 4
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: Private.DefaultListItemBackground {}
background: Rectangle {
visible: control.ListView.view ? control.ListView.view.highlight === null : true
opacity: {
if (control.highlighted || control.pressed) {
return 0.7;
} else if (control.hovered && !control.pressed) {
return 0.4;
}
return 0;
}
color: theme.highlightColor
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright 2016 Marco Martin <mart@kde.org>
*
* 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.Window 2.2
import QtQuick.Templates 2.2 as T
import org.kde.plasma.core 2.0 as PlasmaCore
T.Label {
id: control
verticalAlignment: lineCount > 1 ? Text.AlignTop : Text.AlignVCenter
activeFocusOnTab: false
// Work around Qt bug where NativeRendering breaks for non-integer scale factors
// https://bugreports.qt.io/browse/QTBUG-67007
renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering
//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
}

View File

@ -0,0 +1,131 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 by Marco Martin <mart@kde.org>
*
* 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
}
}
]
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 2016 Marco Martin <mart@kde.org>
*
* 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 org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.2 as Kirigami
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: !Kirigami.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))
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2018 by Marco Martin <mart@kde.org>
*
* 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
import org.kde.kirigami 2.5 as Kirigami
Item {
id: root
width: 1 //<-important that this is actually a single device pixel
height: units.gridUnit
property Item target
property bool selectionStartHandle: false
visible: Kirigami.Settings.tabletMode && ((target.activeFocus && !selectionStartHandle) || target.selectedText.length > 0)
Rectangle {
width: Math.round(units.devicePixelRatio * 3)
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
bottom: parent.bottom
}
color: Qt.tint(theme.highlightColor, Qt.rgba(1,1,1,0.4))
radius: width
Rectangle {
width: Math.round(units.gridUnit/1.5)
height: width
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.bottom
}
radius: width
color: Qt.tint(theme.highlightColor, Qt.rgba(1,1,1,0.4))
}
MouseArea {
anchors {
fill: parent
margins: -units.gridUnit
}
preventStealing: true
onPositionChanged: {
var pos = mapToItem(target, mouse.x, mouse.y);
pos = target.positionAt(pos.x, pos.y);
if (target.selectedText.length > 0) {
if (selectionStartHandle) {
target.select(Math.min(pos, target.selectionEnd - 1), target.selectionEnd);
} else {
target.select(target.selectionStart, Math.max(pos, target.selectionStart + 1));
}
} else {
target.cursorPosition = pos;
}
}
}
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 by Marco Martin <mart@kde.org>
*
* 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.
*/
pragma Singleton
import QtQuick 2.1
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.5 as Kirigami
Popup {
id: root
property Item controlRoot
parent: controlRoot ? controlRoot.Window.contentItem : undefined
modal: false
focus: false
closePolicy: Popup.NoAutoClose
x: controlRoot ? Math.min(Math.max(0, controlRoot.mapToItem(root.parent, controlRoot.positionToRectangle(controlRoot.selectionStart).x, 0).x - root.width/2), controlRoot.Window.contentItem.width - root.width) : 0
y: {
if (!controlRoot) {
return false;
}
var desiredY = controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionStart).y).y - root.height;
if (desiredY >= 0) {
return Math.min(desiredY, controlRoot.Window.contentItem.height - root.height);
} else {
return Math.min(Math.max(0, controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionEnd).y + Math.round(units.gridUnit*1.5)).y), controlRoot.Window.contentItem.height - root.height);
}
}
visible: controlRoot ? Kirigami.Settings.tabletMode && (controlRoot.selectedText.length > 0 || controlRoot.canPaste) : false
width: contentItem.implicitWidth + leftPadding + rightPadding
contentItem: RowLayout {
ToolButton {
focusPolicy: Qt.NoFocus
icon.name: "edit-cut"
visible: controlRoot.selectedText.length > 0
onClicked: {
controlRoot.cut();
}
}
ToolButton {
focusPolicy: Qt.NoFocus
icon.name: "edit-copy"
visible: controlRoot.selectedText.length > 0
onClicked: {
controlRoot.copy();
}
}
ToolButton {
focusPolicy: Qt.NoFocus
icon.name: "edit-paste"
onClicked: {
controlRoot.paste();
}
}
}
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 by Marco Martin <mart@kde.org>
*
* 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
}
}
]
}

View File

@ -2,11 +2,15 @@ module org.kde.latte.components
BadgeText 1.0 BadgeText.qml
CheckBox 1.0 CheckBox.qml
ComboBox 1.0 ComboBox.qml
ComboBoxButton 1.0 ComboBoxButton.qml
ExternalShadow 1.0 ExternalShadow.qml
GlowPoint 1.0 GlowPoint.qml
Header 1.0 Header.qml
HeaderSwitch 1.0 HeaderSwitch.qml
IndicatorItem 1.0 IndicatorItem.qml
ItemDelegate 1.0 ItemDelegate.qml
Label 1.0 Label.qml
Slider 1.0 Slider.qml
SpinBox 1.0 SpinBox.qml
SubHeader 1.0 SubHeader.qml

View File

@ -458,52 +458,30 @@ FocusScope {
function updateEnabled() {
var screenFreeEdges = latteView.managedLayout.qmlFreeEdges(latteView.positioner.currentScreenId);
addView.enabled = latteView.managedLayout.viewsCount<4 && screenFreeEdges.length > 0
removeView.enabled = latteView.managedLayout.viewsCount>1 && !(latteView.managedLayout.viewsWithTasks()===1 && latteView.tasksPresent())
actionsComboBtn.buttonEnabled = latteView.managedLayout.viewsCount<4 && screenFreeEdges.length > 0
removeView.enabled = latteView.managedLayout.viewsCount>1 /*&& !(latteView.managedLayout.viewsWithTasks()===1 && latteView.tasksPresent())*/
}
PlasmaComponents.Button {
LatteComponents.ComboBoxButton {
id: actionsComboBtn
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
text:" "
PlasmaComponents3.ComboBox {
id: actionsCmb
anchors.fill: parent
enabled: addView.enabled
comboBoxEnabled: buttonEnabled
buttonEnabled: true
buttonText: i18n("New Dock")
buttonIconSource: "list-add"
buttonToolTip: i18n("Add a new dock")
property var activeLayoutsNames;
property var activeLayoutsNames;
function addModel() {
var actions = []
actions.push(" " + i18n("Copy Dock"));
Component.onCompleted: actionButtons.updateEnabled();
var tempActiveLayouts = layoutManager.activeLayoutsNames();
var currentLayoutIndex = tempActiveLayouts.indexOf(latteView.managedLayout.name);
tempActiveLayouts.splice(currentLayoutIndex,1);
if (tempActiveLayouts.length > 0) {
activeLayoutsNames = tempActiveLayouts;
actions.push(" ------ ");
for(var i=0; i<activeLayoutsNames.length; ++i) {
actions.push(" " + i18n("Move to:") + " " + activeLayoutsNames[i]);
}
}
actionsCmb.model = actions;
actionsCmb.currentIndex = -1;
}
function emptyModel() {
var actions = []
actions.push(" ");
actionsCmb.model = actions;
actionsCmb.currentIndex = -1;
}
Connections{
target: actionsComboBtn.comboBox
Component.onCompleted:{
addModel();
actionsComboBtn.addModel();
}
onActivated: {
@ -513,37 +491,50 @@ FocusScope {
latteView.positioner.hideDockDuringMovingToLayout(activeLayoutsNames[index-2]);
}
actionsCmb.currentIndex = -1;
actionsComboBtn.comboBox.currentIndex = -1;
}
onEnabledChanged: {
if (enabled)
addModel();
else
emptyModel();
if (enabled) {
actionsComboBtn.addModel();
} else {
actionsComboBtn.emptyModel();
}
}
}
//overlayed button
PlasmaComponents.Button {
id: addView
anchors.left: Qt.application.layoutDirection === Qt.RightToLeft ? undefined : parent.left
anchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? parent.right : undefined
LayoutMirroring.enabled: false
Connections{
target: actionsComboBtn.button
width: parent.width - units.iconSizes.medium + 2*units.smallSpacing
height: parent.height
onClicked: latteView.managedLayout.addNewView();
}
text: i18n("New Dock")
iconSource: "list-add"
tooltip: i18n("Add a new dock")
function addModel() {
var actions = []
actions.push(" " + i18n("Copy Dock"));
onClicked: latteView.managedLayout.addNewView()
var tempActiveLayouts = layoutManager.activeLayoutsNames();
var currentLayoutIndex = tempActiveLayouts.indexOf(latteView.managedLayout.name);
Component.onCompleted: {
var screenFreeEdges = latteView.managedLayout.qmlFreeEdges(latteView.positioner.currentScreenId);
enabled = screenFreeEdges.length > 0
tempActiveLayouts.splice(currentLayoutIndex,1);
if (tempActiveLayouts.length > 0) {
activeLayoutsNames = tempActiveLayouts;
actions.push(" ------ ");
for(var i=0; i<activeLayoutsNames.length; ++i) {
actions.push(" " + i18n("Move to:") + " " + activeLayoutsNames[i]);
}
}
actionsComboBtn.comboBox.model = actions;
actionsComboBtn.comboBox.currentIndex = -1;
}
function emptyModel() {
var actions = []
actions.push(" ");
actionsComboBtn.model = actions;
actionsComboBtn.currentIndex = -1;
}
}

View File

@ -70,7 +70,7 @@ PlasmaComponents.Page {
Layout.leftMargin: units.smallSpacing * 2
spacing: units.smallSpacing
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: layoutCmb
Layout.fillWidth: true

View File

@ -132,7 +132,7 @@ PlasmaComponents.Page {
Layout.alignment: Qt.AlignRight
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: screenCmb
Layout.fillWidth: true
Component.onCompleted: screenRow.updateScreens();
@ -531,7 +531,7 @@ PlasmaComponents.Page {
text: i18n("Mouse wheel")
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: scrollAction
Layout.fillWidth: true
model: [i18nc("none scroll actions", "None Action"),

View File

@ -311,7 +311,7 @@ PlasmaComponents.Page {
text: i18n("Left Click")
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: leftClickAction
Layout.fillWidth: true
model: [i18nc("present windows action", "Present Windows"),
@ -350,7 +350,7 @@ PlasmaComponents.Page {
text: i18n("Middle Click")
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: middleClickAction
Layout.fillWidth: true
model: [
@ -370,7 +370,7 @@ PlasmaComponents.Page {
text: i18n("Hover")
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: hoverAction
Layout.fillWidth: true
model: [
@ -420,7 +420,7 @@ PlasmaComponents.Page {
spacing: units.smallSpacing
enabled: !disableAllWindowsFunctionality
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: modifier
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 5
model: ["Shift", "Ctrl", "Alt", "Meta"]
@ -433,7 +433,7 @@ PlasmaComponents.Page {
text: "+"
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: modifierClick
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 10
model: [i18n("Left Click"), i18n("Middle Click"), i18n("Right Click")]
@ -446,7 +446,7 @@ PlasmaComponents.Page {
text: "="
}
PlasmaComponents3.ComboBox {
LatteComponents.ComboBox {
id: modifierClickAction
Layout.fillWidth: true
model: [i18nc("The click action", "None"), i18n("Close Window or Group"),