forked from openkylin/ukui-menu
添加全屏拖拽功能
This commit is contained in:
parent
0098121472
commit
8ca1215ba6
|
@ -162,11 +162,14 @@ RowLayout {
|
||||||
Component {
|
Component {
|
||||||
id: appViewComponent
|
id: appViewComponent
|
||||||
GridView {
|
GridView {
|
||||||
|
id: appGridView
|
||||||
|
property string selectId: ""
|
||||||
ScrollBar.vertical: fullScreenScrollBar
|
ScrollBar.vertical: fullScreenScrollBar
|
||||||
cellWidth: contentViewBase.cellWidth
|
cellWidth: contentViewBase.cellWidth
|
||||||
cellHeight: contentViewBase.cellHeight
|
cellHeight: contentViewBase.cellHeight
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
model: modelManager.getAppModel()
|
model: modelManager.getAppModel()
|
||||||
|
cacheBuffer: cellHeight * appGridView.count / 6
|
||||||
|
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
width: GridView.view.cellWidth
|
width: GridView.view.cellWidth
|
||||||
|
@ -188,8 +191,35 @@ RowLayout {
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: appComponent
|
id: appComponent
|
||||||
|
DropArea {
|
||||||
|
id: dropArea
|
||||||
|
property int originalX
|
||||||
|
property int originalY
|
||||||
|
|
||||||
|
onEntered: {
|
||||||
|
if (appGridView.selectId !== id) {
|
||||||
|
imageBase.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
imageBase.visible = false;
|
||||||
|
}
|
||||||
|
onDropped: {
|
||||||
|
if (appGridView.selectId !== id) {
|
||||||
|
appGridView.model.addAppsToFolder(appGridView.selectId, id, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
Item {
|
Item {
|
||||||
|
id: appItem
|
||||||
|
property bool isSelect: false
|
||||||
|
property bool isEnterd: false
|
||||||
|
width: contentViewBase.cellWidth
|
||||||
|
height: contentViewBase.cellHeight
|
||||||
|
Drag.active: appItemMouseArea.drag.active
|
||||||
|
Drag.hotSpot.x: width / 2
|
||||||
|
Drag.hotSpot.y: height / 2
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: appItemMouseArea
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
width: 170; height: width
|
width: 170; height: width
|
||||||
|
@ -200,34 +230,95 @@ RowLayout {
|
||||||
useStyleTransparent: false
|
useStyleTransparent: false
|
||||||
paletteRole: Palette.Light
|
paletteRole: Palette.Light
|
||||||
radius: 16
|
radius: 16
|
||||||
alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
|
alpha: appItem.isSelect ? 0.00 : parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
|
||||||
AppControls2.IconLabel {
|
|
||||||
|
Item {
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 14
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
height: 108
|
||||||
|
width: 108
|
||||||
|
|
||||||
|
AppControls2.StyleBackground {
|
||||||
|
id: imageBase
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
iconWidth: 96; iconHeight: 96
|
paletteRole: Palette.Text
|
||||||
appName: name; appIcon: icon
|
useStyleTransparent: false
|
||||||
spacing: 8
|
alpha: 0.25
|
||||||
textHighLight: true
|
radius: 24
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
id: iconImage
|
||||||
|
anchors.centerIn: parent
|
||||||
|
height: 96
|
||||||
|
width: 96
|
||||||
|
source: icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AppControls2.StyleText {
|
||||||
|
id: iconText
|
||||||
|
visible: !appItem.isSelect
|
||||||
|
width: parent.width
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: 20
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
text: name
|
||||||
|
font.pixelSize: 14
|
||||||
|
elide: Text.ElideRight
|
||||||
|
paletteRole: Palette.HighlightedText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
modelManager.getAppModel().openMenu(index, MenuInfo.FullScreen);
|
appGridView.model.openMenu(index, MenuInfo.FullScreen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
parent.parent.GridView.view.model.appClicked(index);
|
appGridView.model.appClicked(index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onPressAndHold: {
|
||||||
|
if (mouse.button === Qt.LeftButton) {
|
||||||
|
originalX = appItem.x;
|
||||||
|
originalY = appItem.y;
|
||||||
|
appItem.x = appItem.mapToItem(contentViewBase,0,0).x;
|
||||||
|
appItem.y = appItem.mapToItem(contentViewBase,0,0).y;
|
||||||
|
drag.target = appItem;
|
||||||
|
appItem.parent = contentViewBase;
|
||||||
|
appItem.isSelect = true;
|
||||||
|
appGridView.selectId = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
parent.Drag.drop();
|
||||||
|
appItem.isSelect = false;
|
||||||
|
drag.target = null;
|
||||||
|
appItem.parent = dropArea;
|
||||||
|
appItem.x = originalX;
|
||||||
|
appItem.y = originalY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: normalFolderComponent
|
id: normalFolderComponent
|
||||||
Item {
|
DropArea {
|
||||||
|
onEntered: {
|
||||||
|
folderItem.isSelect = true;
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
folderItem.isSelect = false;
|
||||||
|
}
|
||||||
|
onDropped: {
|
||||||
|
appGridView.model.addAppToFolder(appGridView.selectId, id);
|
||||||
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
@ -241,30 +332,47 @@ RowLayout {
|
||||||
radius: 16
|
radius: 16
|
||||||
alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
|
alpha: parent.containsPress ? 0.25 : parent.containsMouse ? 0.15 : 0.00
|
||||||
|
|
||||||
ColumnLayout {
|
Item {
|
||||||
height: 128; width: parent.width
|
id: folderItem
|
||||||
anchors.centerIn: parent
|
property bool isSelect: false
|
||||||
spacing: 8
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
height: 108; width: 108
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 14
|
||||||
|
|
||||||
|
AppControls2.StyleBackground {
|
||||||
|
anchors.fill: parent
|
||||||
|
paletteRole: Palette.Text
|
||||||
|
useStyleTransparent: false
|
||||||
|
alpha: 0.25
|
||||||
|
radius: 24
|
||||||
|
visible: folderItem.isSelect
|
||||||
|
}
|
||||||
|
|
||||||
AppControls2.FolderIcon {
|
AppControls2.FolderIcon {
|
||||||
id: folderIcon
|
id: folderIcon
|
||||||
Layout.margins: 5
|
width: 96
|
||||||
|
height: 96
|
||||||
rows: 4; columns: 4
|
rows: 4; columns: 4
|
||||||
spacing: 2; padding: 8
|
spacing: 2; padding: 8
|
||||||
icons: icon
|
icons: icon
|
||||||
radius: 16; alpha: 0.25
|
radius: 16; alpha: folderItem.isSelect ? 0 : 0.25
|
||||||
Layout.alignment: Qt.AlignHCenter
|
anchors.centerIn: parent
|
||||||
Layout.preferredWidth: 86; Layout.preferredHeight: 86
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AppControls2.StyleText {
|
AppControls2.StyleText {
|
||||||
Layout.fillWidth: true; Layout.fillHeight: true
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: 20
|
||||||
|
width: parent.width
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
text: name
|
text: name
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
paletteRole: Palette.HighlightedText
|
paletteRole: Palette.HighlightedText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
|
|
Loading…
Reference in New Issue