From f535bc150049a04452681ae69363a5f6cca4f260 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 20 Jan 2023 13:38:40 -0600 Subject: [PATCH] a lot of tweaks to make changing slides work --- src/qml/presenter/LeftDock.qml | 16 +++- src/qml/presenter/MainWindow.qml | 9 ++- src/qml/presenter/Presentation.qml | 78 +++++++++++-------- .../presenter/PreviewSlideListDelegate.qml | 10 +-- src/qml/presenter/ServiceList.qml | 14 ++-- 5 files changed, 75 insertions(+), 52 deletions(-) diff --git a/src/qml/presenter/LeftDock.qml b/src/qml/presenter/LeftDock.qml index 6f44337..fb4babf 100644 --- a/src/qml/presenter/LeftDock.qml +++ b/src/qml/presenter/LeftDock.qml @@ -368,14 +368,22 @@ ColumnLayout { ] } + Connections { + target: ServiceItemModel + onDataChanged: { + if (active) + serviceItemList.positionViewAtIndex(index, ListView.Contain); + } + } + Component.onCompleted: { - totalServiceItems = serviceItemList.count; + /* totalServiceItems = serviceItemList.count; */ console.log("THE TOTAL SERVICE ITEMS: " + totalServiceItems); } function removeItem(index) { ServiceItemModel.removeItem(index); - totalServiceItems--; + /* totalServiceItems--; */ } function addItem(index, name, type, @@ -385,7 +393,7 @@ ColumnLayout { ServiceItemModel.insertItem(index, name, type, background, backgroundType, newtext); - totalServiceItems++; + /* totalServiceItems++; */ } function appendItem(name, type, background, backgroundType, text, itemID) { @@ -402,7 +410,7 @@ ColumnLayout { ServiceItemModel.addItem(name, type, background, backgroundType, lyrics); - totalServiceItems++; + /* totalServiceItems++; */ } } diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index 025c001..191790f 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -13,11 +13,13 @@ Controls.Page { // properties passed around for the slides property int currentServiceItem + property int currentSlide + property int totalServiceItems: ServiceItemModel.rowCount() + property int totalSlides: SlideModel.rowCount() property url imageBackground: presentation.imageBackground property url videoBackground: presentation.vidBackground property string currentText: presentation.text property int blurRadius: 0 - property int totalServiceItems /* property var video */ property int dragItemIndex @@ -153,6 +155,9 @@ Controls.Page { function changeServiceItem(index) { const item = ServiceItemModel.getItem(index); currentServiceItem = index; + const slideId = SlideModel.findSlideIdFromServItm(index); + currentSlide = slideId; + const slide = SlideModel.getItem(slideId); console.log("index grabbed: " + index); console.log(item); @@ -162,7 +167,7 @@ Controls.Page { console.log("Time to start changing"); ServiceItemModel.activate(index); - SlideObject.changeSlide(item); + SlideObject.changeSlide(slide); /* if (item.backgroundType === "video") */ /* { */ diff --git a/src/qml/presenter/Presentation.qml b/src/qml/presenter/Presentation.qml index 3d2bcd4..681c621 100644 --- a/src/qml/presenter/Presentation.qml +++ b/src/qml/presenter/Presentation.qml @@ -183,7 +183,7 @@ FocusScope { anchors.top: mainGrid.bottom anchors.bottom: root.bottom - Kirigami.Units.gridUnit width: parent.width - orientation: ListView.Horizontal + orientation: Qt.Horizontal spacing: Kirigami.Units.smallSpacing * 2 cacheBuffer: 900 reuseItems: true @@ -194,10 +194,6 @@ FocusScope { id: wheelHandler target: previewSlidesList filterMouseEvents: true - onWheel: { - wheel.accepted = true; - showPassiveNotification(wheel.inverted) - } } } @@ -279,21 +275,28 @@ FocusScope { function nextSlideAction() { keyHandler.forceActiveFocus(); console.log(currentServiceItem); - const nextServiceItemIndex = currentServiceItem + 1; - const nextItem = ServiceItemModel.getItem(nextServiceItemIndex); - 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) + const nextSlideIdx = currentSlide + 1; + if (nextSlideIdx > totalSlides || nextSlideIdx < 0) return; - if (change) { - SlideObject.changeSlide(nextItem); - currentServiceItem++; - changeServiceItem(currentServiceItem); - leftDock.changeItem(); - } + const nextItem = SlideModel.getItem(nextSlideIdx); + console.log("currentServiceItem " + currentServiceItem); + console.log("currentSlide " + currentSlide); + console.log("nextSlideIdx " + nextSlideIdx); + 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() { @@ -303,22 +306,29 @@ FocusScope { function previousSlideAction() { keyHandler.forceActiveFocus(); - const prevServiceItemIndex = currentServiceItem - 1; - const prevItem = ServiceItemModel.getItem(prevServiceItemIndex); - console.log("currentServiceItem " + currentServiceItem); - console.log("prevServiceItem " + prevServiceItemIndex); - console.log(prevItem.name); - const change = SlideObject.previous(prevItem); - console.log(change); - if (currentServiceItem === 0 & change) { + const prevSlideIdx = currentSlide - 1; + if (prevSlideIdx > totalSlides || prevSlideIdx < 0) return; - }; - if (change) { - SlideObject.changeSlide(prevItem); - currentServiceItem--; - changeServiceItem(currentServiceItem); - leftDock.changeItem(); - } + const prevItem = SlideModel.getItem(prevSlideIdx); + console.log("currentServiceItem " + currentServiceItem); + console.log("currentSlide " + currentSlide); + console.log("prevSlideIdx " + prevSlideIdx); + console.log(prevItem.index); + 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() { diff --git a/src/qml/presenter/PreviewSlideListDelegate.qml b/src/qml/presenter/PreviewSlideListDelegate.qml index a225757..c8f1a82 100644 --- a/src/qml/presenter/PreviewSlideListDelegate.qml +++ b/src/qml/presenter/PreviewSlideListDelegate.qml @@ -7,8 +7,6 @@ import org.presenter 1.0 Item { id: root - // Lets set the outerModelData so we can access that data here. - implicitHeight: Kirigami.Units.gridUnit * 6.5 implicitWidth: Kirigami.Units.gridUnit * 10 Rectangle { @@ -59,7 +57,7 @@ Item { id: previewerMouse anchors.fill: parent hoverEnabled: true - /* onClicked: changeServiceItem(index) */ + onClicked: changeServiceItem(index) cursorShape: Qt.PointingHandCursor propagateComposedEvents: true } @@ -67,8 +65,10 @@ Item { Connections { target: SlideModel - onDataChanged: if (active) - previewSlidesList.positionViewAtIndex(index, ListView.Contain) + onDataChanged: { + if (active) + previewSlidesList.positionViewAtIndex(index, ListView.Contain); + } } function changeSlideAndIndex(serviceItem, index) { diff --git a/src/qml/presenter/ServiceList.qml b/src/qml/presenter/ServiceList.qml index a62276c..c32b8b3 100644 --- a/src/qml/presenter/ServiceList.qml +++ b/src/qml/presenter/ServiceList.qml @@ -502,13 +502,13 @@ Item { } Component.onCompleted: { - totalServiceItems = serviceItemList.count; + /* totalServiceItems = serviceItemList.count; */ console.log("THE TOTAL SERVICE ITEMS: " + totalServiceItems); } function removeItem(index) { ServiceItemModel.removeItem(index); - totalServiceItems--; + /* totalServiceItems--; */ } function addItem(index, name, type, @@ -521,7 +521,7 @@ Item { type, background, backgroundType, newtext, audio, font, fontSize, newtext.length); - totalServiceItems++; + /* totalServiceItems++; */ return; } if (type === "presentation") { @@ -530,14 +530,14 @@ Item { type, background, backgroundType, "", "", "", 0, dragItemSlideNumber); - totalServiceItems++; + /* totalServiceItems++; */ return; } console.log("adding: " + name + " of type " + type); ServiceItemModel.insertItem(index, name, type, background, backgroundType); - totalServiceItems++; + /* totalServiceItems++; */ } function appendItem(name, type, background, backgroundType, @@ -552,7 +552,7 @@ Item { ServiceItemModel.addItem(name, type, background, backgroundType, lyrics, audio, font, fontSize); - totalServiceItems++; + /* totalServiceItems++; */ return; }; @@ -561,7 +561,7 @@ Item { ServiceItemModel.addItem(name, type, background, backgroundType); - totalServiceItems++; + /* totalServiceItems++; */ } function changeItem() {