Switch to ItemDelegate for PCs and Apps for proper hover and click behavior

This commit is contained in:
Cameron Gutman
2018-09-05 17:08:27 -07:00
parent bd9f2d2009
commit a7517dace3
2 changed files with 50 additions and 53 deletions
+9 -10
View File
@@ -16,8 +16,7 @@ GridView {
anchors.topMargin: 20 anchors.topMargin: 20
anchors.rightMargin: 5 anchors.rightMargin: 5
anchors.bottomMargin: 5 anchors.bottomMargin: 5
cellWidth: 225; cellHeight: 350; cellWidth: 225; cellHeight: 385;
focus: true
// Cache delegates for 1000px in both directions to improve // Cache delegates for 1000px in both directions to improve
// scrolling and resizing performance // scrolling and resizing performance
@@ -52,12 +51,13 @@ GridView {
model: appModel model: appModel
delegate: Item { delegate: ItemDelegate {
width: 200; height: 300; width: 200; height: 335;
Image { Image {
id: appIcon id: appIcon
anchors.horizontalCenter: parent.horizontalCenter; anchors.horizontalCenter: parent.horizontalCenter;
y: 20
source: model.boxart source: model.boxart
sourceSize { sourceSize {
width: 150 width: 150
@@ -132,20 +132,19 @@ GridView {
} }
} }
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: { onClicked: {
if (mouse.button === Qt.LeftButton) {
// Nothing is running or this app is running // Nothing is running or this app is running
launchOrResumeSelectedApp() launchOrResumeSelectedApp()
} }
else {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
// Right click // Right click
appContextMenu.open() appContextMenu.open()
} }
} }
}
Menu { Menu {
id: appContextMenu id: appContextMenu
+9 -11
View File
@@ -19,7 +19,6 @@ GridView {
anchors.rightMargin: 5 anchors.rightMargin: 5
anchors.bottomMargin: 5 anchors.bottomMargin: 5
cellWidth: 350; cellHeight: 350; cellWidth: 350; cellHeight: 350;
focus: true
objectName: "Computers" objectName: "Computers"
// The StackView will trigger a visibility change when // The StackView will trigger a visibility change when
@@ -73,7 +72,7 @@ GridView {
model: computerModel model: computerModel
delegate: Item { delegate: ItemDelegate {
width: 300; height: 300; width: 300; height: 300;
Image { Image {
@@ -142,11 +141,7 @@ GridView {
} }
} }
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton;
onClicked: { onClicked: {
if(mouse.button === Qt.LeftButton) {
if (model.addPc) { if (model.addPc) {
addPcDialog.open() addPcDialog.open()
} }
@@ -174,19 +169,22 @@ GridView {
errorDialog.open() errorDialog.open()
} }
} }
} else if(!model.online) { } else if (!model.online) {
pcContextMenu.open() pcContextMenu.open()
} }
}
} MouseArea {
else { // right click anchors.fill: parent
if(!model.addPc) { // but only for actual PCs, not the add-pc option acceptedButtons: Qt.RightButton;
onClicked: {
// right click
if (!model.addPc) { // but only for actual PCs, not the add-pc option
pcContextMenu.open() pcContextMenu.open()
} }
} }
} }
} }
}
MessageDialog { MessageDialog {
id: errorDialog id: errorDialog