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