mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
fix: Replace context menu to system specific
This commit is contained in:
@@ -4,12 +4,13 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import Qt.labs.platform as Platform
|
||||||
import ChatView
|
import ChatView
|
||||||
import UIControls
|
import UIControls
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property alias attachedFilesModel: attachRepeater.model
|
property alias attachedFilesModel: attachRepeater.model
|
||||||
property color accentColor: palette.mid
|
property color accentColor: palette.mid
|
||||||
property string iconPath
|
property string iconPath
|
||||||
@@ -21,10 +22,10 @@ Flow {
|
|||||||
rightPadding: 5
|
rightPadding: 5
|
||||||
topPadding: attachRepeater.model.length > 0 ? 2 : 0
|
topPadding: attachRepeater.model.length > 0 ? 2 : 0
|
||||||
bottomPadding: attachRepeater.model.length > 0 ? 2 : 0
|
bottomPadding: attachRepeater.model.length > 0 ? 2 : 0
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: attachRepeater
|
id: attachRepeater
|
||||||
|
|
||||||
delegate: FileItem {
|
delegate: FileItem {
|
||||||
id: fileItem
|
id: fileItem
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ Flow {
|
|||||||
required property string modelData
|
required property string modelData
|
||||||
|
|
||||||
filePath: modelData
|
filePath: modelData
|
||||||
|
|
||||||
height: 30
|
height: 30
|
||||||
width: contentRow.width + 10
|
width: contentRow.width + 10
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ Flow {
|
|||||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||||
onClicked: (mouse) => {
|
onClicked: (mouse) => {
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
contextMenu.popup()
|
contextMenu.open()
|
||||||
} else if (mouse.button === Qt.MiddleButton ||
|
} else if (mouse.button === Qt.MiddleButton ||
|
||||||
(mouse.button === Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier))) {
|
(mouse.button === Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier))) {
|
||||||
root.removeFileFromListByIndex(fileItem.index)
|
root.removeFileFromListByIndex(fileItem.index)
|
||||||
@@ -70,27 +71,27 @@ Flow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu {
|
Platform.Menu {
|
||||||
id: contextMenu
|
id: contextMenu
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: "Open in Qt Creator"
|
text: qsTr("Open in Qt Creator")
|
||||||
onTriggered: fileItem.openFileInEditor()
|
onTriggered: fileItem.openFileInEditor()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: "Open in External Editor"
|
text: qsTr("Open in External Editor")
|
||||||
onTriggered: fileItem.openFileInExternalEditor()
|
onTriggered: fileItem.openFileInExternalEditor()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuSeparator {}
|
Platform.MenuSeparator {}
|
||||||
|
|
||||||
MenuItem {
|
Platform.MenuItem {
|
||||||
text: "Remove"
|
text: qsTr("Remove")
|
||||||
onTriggered: root.removeFileFromListByIndex(fileItem.index)
|
onTriggered: root.removeFileFromListByIndex(fileItem.index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: contentRow
|
id: contentRow
|
||||||
|
|
||||||
@@ -107,31 +108,31 @@ Flow {
|
|||||||
sourceSize.width: 8
|
sourceSize.width: 8
|
||||||
sourceSize.height: 15
|
sourceSize.height: 15
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: fileNameText
|
id: fileNameText
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
color: palette.buttonText
|
color: palette.buttonText
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
const parts = modelData.split('/');
|
const parts = modelData.split('/');
|
||||||
return parts[parts.length - 1];
|
return parts[parts.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: closeButton
|
id: closeButton
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
width: closeIcon.width + 5
|
width: closeIcon.width + 5
|
||||||
height: closeButton.width + 5
|
height: closeButton.width + 5
|
||||||
|
|
||||||
onClicked: root.removeFileFromListByIndex(index)
|
onClicked: root.removeFileFromListByIndex(index)
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: closeIcon
|
id: closeIcon
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
source: palette.window.hslLightness > 0.5 ? "qrc:/qt/qml/ChatView/icons/close-dark.svg"
|
source: palette.window.hslLightness > 0.5 ? "qrc:/qt/qml/ChatView/icons/close-dark.svg"
|
||||||
: "qrc:/qt/qml/ChatView/icons/close-light.svg"
|
: "qrc:/qt/qml/ChatView/icons/close-light.svg"
|
||||||
|
|||||||
Reference in New Issue
Block a user