Quick GUI: Make entry icon clickable, show menu on right/long click
This commit is contained in:
parent
a8681e6af1
commit
a16021ca9a
|
@ -1,7 +1,7 @@
|
||||||
import QtQuick 2.4
|
import QtQuick 2.4
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import QtQml.Models 2.2
|
import QtQml.Models 2.2
|
||||||
import QtQuick.Controls 2.1 as Controls
|
import QtQuick.Controls 2.4 as Controls
|
||||||
import org.kde.kirigami 2.5 as Kirigami
|
import org.kde.kirigami 2.5 as Kirigami
|
||||||
|
|
||||||
Kirigami.ScrollablePage {
|
Kirigami.ScrollablePage {
|
||||||
|
@ -235,24 +235,63 @@ Kirigami.ScrollablePage {
|
||||||
rootIndex, oldIndex, 1, rootIndex,
|
rootIndex, oldIndex, 1, rootIndex,
|
||||||
oldIndex < newIndex ? newIndex + 1 : newIndex)
|
oldIndex < newIndex ? newIndex + 1 : newIndex)
|
||||||
}
|
}
|
||||||
Kirigami.Icon {
|
Item {
|
||||||
width: Kirigami.Units.iconSizes.smallMedium
|
|
||||||
height: Kirigami.Units.iconSizes.smallMedium
|
|
||||||
Layout.fillHeight: true
|
|
||||||
source: delegateModel.isNode(
|
|
||||||
index) ? "folder-symbolic" : "story-editor"
|
|
||||||
}
|
|
||||||
Controls.Label {
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
height: Math.max(implicitHeight,
|
RowLayout {
|
||||||
Kirigami.Units.iconSizes.smallMedium)
|
anchors.fill: parent
|
||||||
text: model.name
|
Kirigami.Icon {
|
||||||
|
width: Kirigami.Units.iconSizes.smallMedium
|
||||||
|
height: Kirigami.Units.iconSizes.smallMedium
|
||||||
|
Layout.fillHeight: true
|
||||||
|
source: delegateModel.isNode(
|
||||||
|
index) ? "folder-symbolic" : "story-editor"
|
||||||
|
}
|
||||||
|
Controls.Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
height: Math.max(
|
||||||
|
implicitHeight,
|
||||||
|
Kirigami.Units.iconSizes.smallMedium)
|
||||||
|
text: model.name
|
||||||
|
}
|
||||||
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: delegateModel.handleEntryClicked(index,
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
model.name)
|
onClicked: {
|
||||||
|
if (mouse.button === Qt.RightButton) {
|
||||||
|
entryContextMenu.popup()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delegateModel.handleEntryClicked(index, model.name)
|
||||||
|
}
|
||||||
|
onPressAndHold: entryContextMenu.popup()
|
||||||
|
}
|
||||||
|
Controls.Menu {
|
||||||
|
id: entryContextMenu
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: "edit-cut"
|
||||||
|
text: qsTr("Cut")
|
||||||
|
onTriggered: {
|
||||||
|
nativeInterface.cutEntry(
|
||||||
|
entryModel.index(index, 0,
|
||||||
|
rootIndex))
|
||||||
|
showPassiveNotification(text + " " + model.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: "edit-delete"
|
||||||
|
text: qsTr("Delete")
|
||||||
|
onTriggered: confirmDeletionDialog.confirmDeletion(
|
||||||
|
model.name, index)
|
||||||
|
}
|
||||||
|
Controls.MenuItem {
|
||||||
|
icon.name: "edit-rename"
|
||||||
|
text: qsTr("Rename")
|
||||||
|
onTriggered: renameDialog.renameEntry(model.name,
|
||||||
|
index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue