ensuring focus and making nextSlideAction not crash

This commit is contained in:
Chris Cochrun 2022-10-06 06:34:30 -05:00
parent 3e9f8974c9
commit 3b0403fed6
3 changed files with 15 additions and 13 deletions

View file

@ -140,6 +140,7 @@ Controls.Page {
function changeServiceItem(index) { function changeServiceItem(index) {
const item = serviceItemModel.getItem(index); const item = serviceItemModel.getItem(index);
currentServiceItem = index;
print("index grabbed: " + index); print("index grabbed: " + index);
print(item); print(item);
@ -213,7 +214,7 @@ Controls.Page {
imageEditor.visible = false; imageEditor.visible = false;
presentationEditor.visible = false; presentationEditor.visible = false;
presentation.visible = true; presentation.visible = true;
presentation.forceActiveFocus(); presentation.focusTimer = true;
editMode = false; editMode = false;
} }
} else { } else {
@ -223,7 +224,7 @@ Controls.Page {
imageEditor.visible = false; imageEditor.visible = false;
presentationEditor.visible = false; presentationEditor.visible = false;
presentation.visible = true; presentation.visible = true;
presentation.forceActiveFocus(); presentation.focusTimer = true;
editMode = false; editMode = false;
presenting = true; presenting = true;
} }

View file

@ -19,6 +19,8 @@ FocusScope {
property Item slide: previewSlide property Item slide: previewSlide
property bool focusTimer: true
Item { Item {
id: keyHandler id: keyHandler
anchors.fill: parent anchors.fill: parent
@ -63,11 +65,6 @@ FocusScope {
Controls.ToolSeparator {} Controls.ToolSeparator {}
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
Controls.ToolSeparator {} Controls.ToolSeparator {}
Controls.ToolButton {
text: "Repeat"
icon.name: "repeat"
onClicked: mainPage.loopVideo()
}
Controls.ToolButton { Controls.ToolButton {
text: "Effects" text: "Effects"
icon.name: "image-auto-adjust" icon.name: "image-auto-adjust"
@ -161,6 +158,10 @@ FocusScope {
visible: itemType === "video"; visible: itemType === "video";
checked: previewSlide.mpvLoop === "inf" ? true : false checked: previewSlide.mpvLoop === "inf" ? true : false
onToggled: mainPage.loopVideo() onToggled: mainPage.loopVideo()
Keys.onLeftPressed: previousSlideAction()
Keys.onRightPressed: nextSlideAction()
Keys.onUpPressed: previousSlideAction()
Keys.onDownPressed: nextSlideAction()
} }
} }
@ -276,8 +277,8 @@ FocusScope {
Timer { Timer {
interval: 500 interval: 500
running: true running: false
repeat: true repeat: focusTimer
onTriggered: root.visible ? keyHandler.forceActiveFocus() : null onTriggered: root.visible ? keyHandler.forceActiveFocus() : null
} }
@ -300,8 +301,9 @@ FocusScope {
} }
function nextSlideAction() { function nextSlideAction() {
root.forceActiveFocus(); keyHandler.forceActiveFocus();
if (currentServiceItem === totalServiceItems) print(currentServiceItem);
if (currentServiceItem === totalServiceItems - 1)
return; return;
const nextServiceItemIndex = currentServiceItem + 1; const nextServiceItemIndex = currentServiceItem + 1;
const nextItem = serviceItemModel.getItem(nextServiceItemIndex); const nextItem = serviceItemModel.getItem(nextServiceItemIndex);
@ -323,7 +325,7 @@ FocusScope {
} }
function previousSlideAction() { function previousSlideAction() {
root.forceActiveFocus(); keyHandler.forceActiveFocus();
if (currentServiceItem === 0) { if (currentServiceItem === 0) {
return; return;
}; };

View file

@ -246,7 +246,6 @@ Item {
onDoubleClicked: { onDoubleClicked: {
/* showPassiveNotification("Double Clicked") */ /* showPassiveNotification("Double Clicked") */
/* serviceItemList.currentIndex = index; */ /* serviceItemList.currentIndex = index; */
currentServiceItem = index;
changeServiceItem(index); changeServiceItem(index);
} }