Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions qml/Helper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ QtObject {

property D.Palette itemBackground: D.Palette {
normal {
common: Qt.rgba(0, 0, 0, 0.1)
crystal: Qt.rgba(0, 0, 0, 0.1)
}
normalDark {
common: Qt.rgba(1, 1, 1, 0.1)
crystal: Qt.rgba(1, 1, 1, 0.1)
common: ("transparent")
crystal: ("transparent")
}
hovered {
common: Qt.rgba(0, 0, 0, 0.1)
Expand Down
77 changes: 24 additions & 53 deletions qml/windowed/AppListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ FocusScope {
leftMargin: 10
rightMargin: 10
}
visible: !dragHandler.active
visible: !Drag.active
text: model.display
checkable: false
icon.name: (iconName && iconName !== "") ? iconName : "application-x-desktop"
Expand Down Expand Up @@ -206,69 +206,40 @@ FocusScope {
ToolTip.visible: hovered && contentItem.implicitWidth > contentItem.width

Drag.dragType: Drag.Automatic
Drag.active: mouseArea.drag.active
Drag.mimeData: Helper.generateDragMimeData(model.desktopId, true)
Drag.hotSpot.y: height / 2
Drag.hotSpot.x: width / 2

states: State {
name: "dragged";
when: dragHandler.active
// FIXME: When dragging finished, the position of the item is changed for unknown reason,
// so we use the state to reset the x and y here.
PropertyChanges {
target: dragHandler.target
x: x
y: y
}
}

TapHandler {
acceptedButtons: Qt.RightButton
onTapped: {
showContextMenu(itemDelegate, model)
baseLayer.focus = true
}
}

DragHandler {
id: dragHandler
target: parent
acceptedButtons: Qt.LeftButton
dragThreshold: 1
MouseArea {
id: mouseArea
anchors.fill: parent

acceptedButtons: Qt.LeftButton | Qt.RightButton
drag.target: itemDelegate
// 当分类菜单打开时,禁用拖拽功能
enabled: !(ddeCategoryMenu.visible || alphabetCategoryPopup.visible)
onActiveChanged: {
if (active) {
// We switch to use the `dndItem` to handle Drag event since that one will always exists.
// If we use the current item, then if the item that provides the drag attached property
// get destoryed (e.g. switch page or folder close caused destory), dropping at that moment
// will cause a crash.
dndItem.Drag.hotSpot = target.Drag.hotSpot
dndItem.Drag.mimeData = target.Drag.mimeData

parent.grabToImage(function(result) {
dndItem.Drag.imageSource = result.url;
dndItem.Drag.active = true
dndItem.Drag.startDrag()

onPressed: function (mouse) {
if (mouse.button === Qt.LeftButton) {
itemDelegate.contentItem.grabToImage(function(result) {
itemDelegate.Drag.imageSource = result.url
})
}
}
}

background: Loader {
active: !dragHandler.active
sourceComponent: ItemBackground {
focusPolicy: Qt.NoFocus
implicitWidth: DStyle.Style.itemDelegate.width
implicitHeight: Helper.windowed.listItemHeight
button: itemDelegate
onClicked: function (mouse) {
if (mouse.button === Qt.RightButton) {
showContextMenu(itemDelegate, model)
baseLayer.focus = true
} else {
launchApp(desktopId)
Comment on lines +234 to +235

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Launching app on non-right click may trigger unintended launches.

Restrict the launchApp call to left mouse button clicks to prevent unintended launches from other buttons.

}
}
}

TapHandler {
onTapped: {
launchApp(desktopId)
}
background: ItemBackground {
implicitWidth: DStyle.Style.itemDelegate.width
implicitHeight: Helper.windowed.listItemHeight
button: itemDelegate
}

Keys.onReturnPressed: {
Expand Down
6 changes: 1 addition & 5 deletions qml/windowed/FreeSortListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,8 @@ Item {

onPressed: function (mouse) {
if (mouse.button === Qt.LeftButton) {
bg.visible = false
itemDelegate.grabToImage(function(result) {
itemDelegate.contentItem.grabToImage(function(result) {
itemDelegate.Drag.imageSource = result.url
bg.visible = Qt.binding(function() {
return bg.ColorSelector.controlState === DTK.HoveredState
})
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions qml/windowed/ItemBackground.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ D.BoxPanel {

implicitWidth: DS.Style.toolButton.width
implicitHeight: DS.Style.toolButton.height
color1: selectValue(background, DS.Style.checkedButton.background, DS.Style.highlightedButton.background1)
color2: selectValue(background, DS.Style.checkedButton.background, DS.Style.highlightedButton.background2)
color1: background
color2: background
insideBorderColor: null
outsideBorderColor: null
visible: {
Expand Down