making sure presentation has focus when viewed

This commit is contained in:
Chris Cochrun 2022-10-05 09:41:18 -05:00
parent c1f0e87056
commit 7c281c1d1e
3 changed files with 26 additions and 26 deletions

View file

@ -24,6 +24,8 @@ Kirigami.ApplicationWindow {
signal edit()
onActiveFocusItemChanged: showPassiveNotification("CHANGED TO: " + activeFocusControl)
pageStack.initialPage: mainPage
header: Presenter.Header {}

View file

@ -43,7 +43,8 @@ Controls.Page {
property string editType
Component.onCompleted: {refocusTimer.start(); changeServiceItem(0);}
Component.onCompleted: {changeServiceItem(0); presentation.forceActiveFocus();}
Item {
id: mainItem
anchors.fill: parent
@ -68,7 +69,7 @@ Controls.Page {
z: 1
}
Item {
FocusScope {
id: mainPageArea
Controls.SplitView.fillWidth: true
Controls.SplitView.minimumWidth: 100
@ -76,6 +77,7 @@ Controls.Page {
Presenter.Presentation {
id: presentation
anchors.fill: parent
focus: true
}
Presenter.SongEditor {
@ -108,7 +110,7 @@ Controls.Page {
Controls.SplitView.preferredWidth: libraryOpen ? 200 : 0
Controls.SplitView.maximumWidth: 350
}
}
}
@ -136,24 +138,6 @@ Controls.Page {
id: serviceItemModel
}
Timer {
id: refocusTimer
interval: 500
repeat: true
onTriggered: keyHandler.forceActiveFocus()
}
Item {
id: keyHandler
anchors.fill: parent
focus: true
Keys.onLeftPressed: presentation.previousSlideAction()
Keys.onRightPressed: presentation.nextSlideAction()
Keys.onUpPressed: presentation.previousSlideAction()
Keys.onDownPressed: presentation.nextSlideAction()
Keys.onSpacePressed: presentation.nextSlideAction()
}
function changeServiceItem(index) {
const item = serviceItemModel.getItem(index);
print("index grabbed: " + index);
@ -181,7 +165,6 @@ Controls.Page {
function editSwitch(item) {
if (editMode) {
refocusTimer.repeat = false;
switch (editType) {
case "song" :
presentation.visible = false;
@ -225,6 +208,7 @@ Controls.Page {
imageEditor.visible = false;
presentationEditor.visible = false;
presentation.visible = true;
presentation.forceActiveFocus();
editMode = false;
}
} else {
@ -234,8 +218,8 @@ Controls.Page {
imageEditor.visible = false;
presentationEditor.visible = false;
presentation.visible = true;
presentation.forceActiveFocus();
editMode = false;
refocusTimer.repeat = true;
presenting = true;
}
}

View file

@ -8,7 +8,7 @@ import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import org.presenter 1.0
Item {
FocusScope {
id: root
property var text
@ -19,6 +19,19 @@ Item {
property Item slide: previewSlide
onActiveFocusChanged: showPassiveNotification("OUCH")
Item {
id: keyHandler
anchors.fill: parent
focus: true
Keys.onLeftPressed: previousSlideAction()
Keys.onRightPressed: nextSlideAction()
Keys.onUpPressed: previousSlideAction()
Keys.onDownPressed: nextSlideAction()
Keys.onSpacePressed: nextSlideAction()
}
/* Component.onCompleted: nextSlideAction() */
GridLayout {
@ -213,8 +226,7 @@ Item {
Connections {
target: serviceItemModel
onDataChanged: if (active)
previewSlidesList.positionViewAtIndex(index,
ListView.Center)
previewSlidesList.positionViewAtIndex(index, ListView.Center)
}
}
Kirigami.WheelHandler {
@ -267,6 +279,7 @@ Item {
}
function nextSlideAction() {
root.forceActiveFocus();
if (currentServiceItem === totalServiceItems)
return;
const nextServiceItemIndex = currentServiceItem + 1;
@ -289,6 +302,7 @@ Item {
}
function previousSlideAction() {
root.forceActiveFocus();
if (currentServiceItem === 0) {
return;
};