a lot of tweaks to make changing slides work

This commit is contained in:
Chris Cochrun 2023-01-20 13:38:40 -06:00
parent a024a0b27d
commit f535bc1500
5 changed files with 75 additions and 52 deletions

View file

@ -368,14 +368,22 @@ ColumnLayout {
] ]
} }
Connections {
target: ServiceItemModel
onDataChanged: {
if (active)
serviceItemList.positionViewAtIndex(index, ListView.Contain);
}
}
Component.onCompleted: { Component.onCompleted: {
totalServiceItems = serviceItemList.count; /* totalServiceItems = serviceItemList.count; */
console.log("THE TOTAL SERVICE ITEMS: " + totalServiceItems); console.log("THE TOTAL SERVICE ITEMS: " + totalServiceItems);
} }
function removeItem(index) { function removeItem(index) {
ServiceItemModel.removeItem(index); ServiceItemModel.removeItem(index);
totalServiceItems--; /* totalServiceItems--; */
} }
function addItem(index, name, type, function addItem(index, name, type,
@ -385,7 +393,7 @@ ColumnLayout {
ServiceItemModel.insertItem(index, name, ServiceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType, newtext); backgroundType, newtext);
totalServiceItems++; /* totalServiceItems++; */
} }
function appendItem(name, type, background, backgroundType, text, itemID) { function appendItem(name, type, background, backgroundType, text, itemID) {
@ -402,7 +410,7 @@ ColumnLayout {
ServiceItemModel.addItem(name, type, background, ServiceItemModel.addItem(name, type, background,
backgroundType, lyrics); backgroundType, lyrics);
totalServiceItems++; /* totalServiceItems++; */
} }
} }

View file

@ -13,11 +13,13 @@ Controls.Page {
// properties passed around for the slides // properties passed around for the slides
property int currentServiceItem property int currentServiceItem
property int currentSlide
property int totalServiceItems: ServiceItemModel.rowCount()
property int totalSlides: SlideModel.rowCount()
property url imageBackground: presentation.imageBackground property url imageBackground: presentation.imageBackground
property url videoBackground: presentation.vidBackground property url videoBackground: presentation.vidBackground
property string currentText: presentation.text property string currentText: presentation.text
property int blurRadius: 0 property int blurRadius: 0
property int totalServiceItems
/* property var video */ /* property var video */
property int dragItemIndex property int dragItemIndex
@ -153,6 +155,9 @@ Controls.Page {
function changeServiceItem(index) { function changeServiceItem(index) {
const item = ServiceItemModel.getItem(index); const item = ServiceItemModel.getItem(index);
currentServiceItem = index; currentServiceItem = index;
const slideId = SlideModel.findSlideIdFromServItm(index);
currentSlide = slideId;
const slide = SlideModel.getItem(slideId);
console.log("index grabbed: " + index); console.log("index grabbed: " + index);
console.log(item); console.log(item);
@ -162,7 +167,7 @@ Controls.Page {
console.log("Time to start changing"); console.log("Time to start changing");
ServiceItemModel.activate(index); ServiceItemModel.activate(index);
SlideObject.changeSlide(item); SlideObject.changeSlide(slide);
/* if (item.backgroundType === "video") */ /* if (item.backgroundType === "video") */
/* { */ /* { */

View file

@ -183,7 +183,7 @@ FocusScope {
anchors.top: mainGrid.bottom anchors.top: mainGrid.bottom
anchors.bottom: root.bottom - Kirigami.Units.gridUnit anchors.bottom: root.bottom - Kirigami.Units.gridUnit
width: parent.width width: parent.width
orientation: ListView.Horizontal orientation: Qt.Horizontal
spacing: Kirigami.Units.smallSpacing * 2 spacing: Kirigami.Units.smallSpacing * 2
cacheBuffer: 900 cacheBuffer: 900
reuseItems: true reuseItems: true
@ -194,10 +194,6 @@ FocusScope {
id: wheelHandler id: wheelHandler
target: previewSlidesList target: previewSlidesList
filterMouseEvents: true filterMouseEvents: true
onWheel: {
wheel.accepted = true;
showPassiveNotification(wheel.inverted)
}
} }
} }
@ -279,21 +275,28 @@ FocusScope {
function nextSlideAction() { function nextSlideAction() {
keyHandler.forceActiveFocus(); keyHandler.forceActiveFocus();
console.log(currentServiceItem); console.log(currentServiceItem);
const nextServiceItemIndex = currentServiceItem + 1; const nextSlideIdx = currentSlide + 1;
const nextItem = ServiceItemModel.getItem(nextServiceItemIndex); if (nextSlideIdx > totalSlides || nextSlideIdx < 0)
console.log("currentServiceItem " + currentServiceItem);
console.log("nextServiceItem " + nextServiceItemIndex);
console.log(nextItem.name);
const change = SlideObject.next(nextItem);
console.log(change);
if (currentServiceItem === totalServiceItems - 1 & change)
return; return;
if (change) { const nextItem = SlideModel.getItem(nextSlideIdx);
SlideObject.changeSlide(nextItem); console.log("currentServiceItem " + currentServiceItem);
currentServiceItem++; console.log("currentSlide " + currentSlide);
changeServiceItem(currentServiceItem); console.log("nextSlideIdx " + nextSlideIdx);
leftDock.changeItem(); console.log(nextItem.index);
} SlideObject.changeSlide(nextItem);
currentSlide = nextSlideIdx;
currentServiceItem = nextItem.serviceItemId;
changeServiceItem(currentServiceItem);
/* const change = SlideObject.next(nextItem); */
/* console.log(change); */
/* if (currentServiceItem === totalServiceItems - 1 & change) */
/* return; */
/* if (change) { */
/* SlideObject.changeSlide(nextItem); */
/* currentServiceItem++; */
/* changeServiceItem(currentServiceItem); */
/* leftDock.changeItem(); */
/* } */
} }
function nextSlide() { function nextSlide() {
@ -303,22 +306,29 @@ FocusScope {
function previousSlideAction() { function previousSlideAction() {
keyHandler.forceActiveFocus(); keyHandler.forceActiveFocus();
const prevServiceItemIndex = currentServiceItem - 1; const prevSlideIdx = currentSlide - 1;
const prevItem = ServiceItemModel.getItem(prevServiceItemIndex); if (prevSlideIdx > totalSlides || prevSlideIdx < 0)
console.log("currentServiceItem " + currentServiceItem);
console.log("prevServiceItem " + prevServiceItemIndex);
console.log(prevItem.name);
const change = SlideObject.previous(prevItem);
console.log(change);
if (currentServiceItem === 0 & change) {
return; return;
}; const prevItem = SlideModel.getItem(prevSlideIdx);
if (change) { console.log("currentServiceItem " + currentServiceItem);
SlideObject.changeSlide(prevItem); console.log("currentSlide " + currentSlide);
currentServiceItem--; console.log("prevSlideIdx " + prevSlideIdx);
changeServiceItem(currentServiceItem); console.log(prevItem.index);
leftDock.changeItem(); SlideObject.changeSlide(prevItem);
} currentSlide = prevSlideIdx;
currentServiceItem = prevItem.serviceItemId;
changeServiceItem(currentServiceItem);
/* const change = SlideObject.previous(prevItem); */
/* console.log(change); */
/* if (currentServiceItem === 0 & change) { */
/* return; */
/* }; */
/* if (change) { */
/* SlideObject.changeSlide(prevItem); */
/* currentServiceItem--; */
/* changeServiceItem(currentServiceItem); */
/* leftDock.changeItem(); */
/* } */
} }
function previousSlide() { function previousSlide() {

View file

@ -7,8 +7,6 @@ import org.presenter 1.0
Item { Item {
id: root id: root
// Lets set the outerModelData so we can access that data here.
implicitHeight: Kirigami.Units.gridUnit * 6.5 implicitHeight: Kirigami.Units.gridUnit * 6.5
implicitWidth: Kirigami.Units.gridUnit * 10 implicitWidth: Kirigami.Units.gridUnit * 10
Rectangle { Rectangle {
@ -59,7 +57,7 @@ Item {
id: previewerMouse id: previewerMouse
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
/* onClicked: changeServiceItem(index) */ onClicked: changeServiceItem(index)
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
propagateComposedEvents: true propagateComposedEvents: true
} }
@ -67,8 +65,10 @@ Item {
Connections { Connections {
target: SlideModel target: SlideModel
onDataChanged: if (active) onDataChanged: {
previewSlidesList.positionViewAtIndex(index, ListView.Contain) if (active)
previewSlidesList.positionViewAtIndex(index, ListView.Contain);
}
} }
function changeSlideAndIndex(serviceItem, index) { function changeSlideAndIndex(serviceItem, index) {

View file

@ -502,13 +502,13 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
totalServiceItems = serviceItemList.count; /* totalServiceItems = serviceItemList.count; */
console.log("THE TOTAL SERVICE ITEMS: " + totalServiceItems); console.log("THE TOTAL SERVICE ITEMS: " + totalServiceItems);
} }
function removeItem(index) { function removeItem(index) {
ServiceItemModel.removeItem(index); ServiceItemModel.removeItem(index);
totalServiceItems--; /* totalServiceItems--; */
} }
function addItem(index, name, type, function addItem(index, name, type,
@ -521,7 +521,7 @@ Item {
type, background, type, background,
backgroundType, newtext, backgroundType, newtext,
audio, font, fontSize, newtext.length); audio, font, fontSize, newtext.length);
totalServiceItems++; /* totalServiceItems++; */
return; return;
} }
if (type === "presentation") { if (type === "presentation") {
@ -530,14 +530,14 @@ Item {
type, background, type, background,
backgroundType, "", backgroundType, "",
"", "", 0, dragItemSlideNumber); "", "", 0, dragItemSlideNumber);
totalServiceItems++; /* totalServiceItems++; */
return; return;
} }
console.log("adding: " + name + " of type " + type); console.log("adding: " + name + " of type " + type);
ServiceItemModel.insertItem(index, name, ServiceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType); backgroundType);
totalServiceItems++; /* totalServiceItems++; */
} }
function appendItem(name, type, background, backgroundType, function appendItem(name, type, background, backgroundType,
@ -552,7 +552,7 @@ Item {
ServiceItemModel.addItem(name, type, background, ServiceItemModel.addItem(name, type, background,
backgroundType, lyrics, backgroundType, lyrics,
audio, font, fontSize); audio, font, fontSize);
totalServiceItems++; /* totalServiceItems++; */
return; return;
}; };
@ -561,7 +561,7 @@ Item {
ServiceItemModel.addItem(name, type, background, ServiceItemModel.addItem(name, type, background,
backgroundType); backgroundType);
totalServiceItems++; /* totalServiceItems++; */
} }
function changeItem() { function changeItem() {