2022-08-28 21:48:51 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2011-2013 Sebastian Kügler <sebas@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2014-2015 Eike Hein <hein@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
import org.kde.ksvg 1.0 as KSvg
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
2022-08-28 21:48:51 +00:00
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.FrameSvgItem {
|
2022-08-28 21:48:51 +00:00
|
|
|
id: upButton
|
|
|
|
|
|
|
|
width: gridView.cellWidth
|
|
|
|
height: visible ? gridView.cellHeight : 0
|
|
|
|
|
|
|
|
visible: history.length !== 0
|
|
|
|
|
|
|
|
property bool ignoreClick: false
|
|
|
|
property bool containsDrag: false
|
|
|
|
|
|
|
|
imagePath: "widgets/viewitem"
|
|
|
|
|
|
|
|
function handleDragMove() {
|
|
|
|
containsDrag = true;
|
|
|
|
hoverActivateTimer.restart();
|
|
|
|
}
|
|
|
|
|
|
|
|
function endDragMove() {
|
|
|
|
containsDrag = false;
|
|
|
|
hoverActivateTimer.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.BackButton
|
|
|
|
hoverEnabled: true
|
|
|
|
|
|
|
|
onContainsMouseChanged: {
|
|
|
|
gridView.hoveredItem = null;
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
onPressed: mouse => {
|
2022-08-28 21:48:51 +00:00
|
|
|
if (mouse.buttons & Qt.BackButton) {
|
2024-08-09 01:20:25 +00:00
|
|
|
if (root.isPopup && dir.resolvedUrl !== dir.resolve(Plasmoid.configuration.url)) {
|
2022-08-28 21:48:51 +00:00
|
|
|
doBack();
|
|
|
|
ignoreClick = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
onClicked: mouse => {
|
2022-08-28 21:48:51 +00:00
|
|
|
if (ignoreClick) {
|
|
|
|
ignoreClick = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
doBack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
Kirigami.Icon {
|
2022-08-28 21:48:51 +00:00
|
|
|
id: icon
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
2024-08-09 01:20:25 +00:00
|
|
|
leftMargin: Kirigami.Units.smallSpacing
|
2022-08-28 21:48:51 +00:00
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
width: gridView.iconSize
|
|
|
|
height: gridView.iconSize
|
|
|
|
|
|
|
|
source: "arrow-left"
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
PlasmaComponents3.Label {
|
2022-08-28 21:48:51 +00:00
|
|
|
id: label
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
left: icon.right
|
2024-08-09 01:20:25 +00:00
|
|
|
leftMargin: Kirigami.Units.smallSpacing * 2
|
2022-08-28 21:48:51 +00:00
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
width: parent.width - icon.width - (Kirigami.Units.smallSpacing * 4);
|
2022-08-28 21:48:51 +00:00
|
|
|
|
|
|
|
height: undefined // Unset PlasmaComponents.Label's default.
|
|
|
|
|
|
|
|
textFormat: Text.PlainText
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
maximumLineCount: root.isPopup ? 1 : Plasmoid.configuration.textLines
|
2022-08-28 21:48:51 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
|
|
|
text: i18n("Back")
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: hoverActivateTimer
|
|
|
|
|
|
|
|
interval: root.hoverActivateDelay
|
|
|
|
|
|
|
|
onTriggered: doBack()
|
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "hover"
|
|
|
|
when: mouseArea.containsMouse || containsDrag
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: upButton
|
|
|
|
prefix: "hover"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|