From 9b6949090e2512a57735ce2f1051931452a1af05 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 30 Mar 2022 11:39:43 -0500 Subject: [PATCH] Working move, and insert, added some changing of slides functionality --- src/qml/presenter/LeftDock.qml | 14 ++++----- src/qml/presenter/MainWindow.qml | 49 +++++++++--------------------- src/qml/presenter/Presentation.qml | 28 +++++++++++++++-- src/qml/presenter/Slide.qml | 11 ++++--- src/serviceitemmodel.cpp | 21 +++++++++++-- src/serviceitemmodel.h | 1 + 6 files changed, 73 insertions(+), 51 deletions(-) diff --git a/src/qml/presenter/LeftDock.qml b/src/qml/presenter/LeftDock.qml index 7b06297..fb8535c 100644 --- a/src/qml/presenter/LeftDock.qml +++ b/src/qml/presenter/LeftDock.qml @@ -111,10 +111,7 @@ ColumnLayout { onMoveRequested: serviceItemModel.move(oldIndex, newIndex) onClicked: { serviceItemList.currentIndex = index; - /* showPassiveNotification(serviceItemList.currentIndex); */ - changeSlideBackground(background, backgroundType); - changeSlideText(text); - changeSlideType(type); + changeServiceItem(index); } } @@ -125,9 +122,9 @@ ColumnLayout { addItem(index, dragItemTitle, dragItemType, - dragItemText, - dragItemBackgroundType, dragItemBackground, + dragItemBackgroundType, + dragItemText, dragItemIndex); } keys: ["library"] @@ -152,9 +149,10 @@ ColumnLayout { function addItem(index, name, type, background, backgroundType, text, itemID) { + const newtext = songsqlmodel.getLyricList(itemID); serviceItemModel.insertItem(index, name, - type, text, background, - backgroundType) + type, background, + backgroundType, newtext); } function appendItem(name, type, background, backgroundType, text, itemID) { diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index 938718d..b5cfbc2 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -133,48 +133,29 @@ Controls.Page { id: serviceItemModel } - function changeSlideType(type) { - presentation.itemType = type; - if (slideItem) - slideItem.itemType = type; - } + function changeServiceItem(index) { + const item = serviceItemModel.getItem(index); - function changeSlideText(text) { - presentation.text = text; - if (slideItem) - slideItem.text = text; - } - - function changeSlideBackground(background, type) { - showPassiveNotification("starting background change.."); - showPassiveNotification(background); - showPassiveNotification(type); - if (type == "image") { + presentation.itemType = item.type; + + if (item.backgroundType === "image") { presentation.vidbackground = ""; - presentation.imagebackground = background; - if (slideItem) { - slideItem.videoSource = ""; - slideItem.stopVideo(); - slideItem.imageSource = background; - } + presentation.imagebackground = item.background; } else { presentation.imagebackground = ""; - presentation.vidbackground = background; + presentation.vidbackground = item.background; presentation.loadVideo() - if (slideItem) { - slideItem.imageSource = ""; - slideItem.videoSource = background; - slideItem.loadVideo() - } } - } - function changeSlideNext() { - showPassiveNotification("next slide please") - } + if (item.text.length === 0) { + presentation.text = [""]; + } + else + presentation.text = item.text; + presentation.textIndex = 0; + presentation.nextSlideText(); - function changeSlidePrevious() { - showPassiveNotification("previous slide please") + print("Slide changed to: " + item.name); } function editSwitch(item) { diff --git a/src/qml/presenter/Presentation.qml b/src/qml/presenter/Presentation.qml index f1647bf..f496730 100644 --- a/src/qml/presenter/Presentation.qml +++ b/src/qml/presenter/Presentation.qml @@ -10,11 +10,14 @@ import "./" as Presenter Item { id: root - property string text + property var text + property int textIndex: 0 property string itemType property url imagebackground property url vidbackground + Component.onCompleted: nextSlideText() + GridLayout { anchors.fill: parent columns: 3 @@ -81,7 +84,6 @@ Item { Layout.minimumWidth: 300 Layout.alignment: Qt.AlignCenter textSize: width / 15 - text: root.text itemType: root.itemType imageSource: imagebackground videoSource: vidbackground @@ -95,7 +97,7 @@ Item { Layout.alignment: Qt.AlignLeft MouseArea { anchors.fill: parent - onPressed: changeSlideNext() + onPressed: nextSlideText() cursorShape: Qt.PointingHandCursor } } @@ -112,4 +114,24 @@ Item { function loadVideo() { previewSlide.loadVideo(); } + + function nextSlideText() { + if (textIndex === 0) { + previewSlide.text = root.text[textIndex]; + print(root.text[textIndex]); + textIndex++; + } else if (textIndex < root.text.length) { + previewSlide.text = root.text[textIndex]; + print(root.text[textIndex]); + textIndex++; + } else { + print("Next slide time"); + nextSlide(); + textIndex = 0; + } + } + + function nextSlide() { + print(slideItem); + } } diff --git a/src/qml/presenter/Slide.qml b/src/qml/presenter/Slide.qml index 099ee58..6a15b68 100644 --- a/src/qml/presenter/Slide.qml +++ b/src/qml/presenter/Slide.qml @@ -15,13 +15,15 @@ Item { property bool editMode: false // These properties are for the slides visuals - property real textSize: 72 + property real textSize: 50 property bool dropShadow: false property url imageSource: imageBackground property url videoSource: videoBackground property string chosenFont: "Quicksand" - property string text: "This is demo text" + property var text: "This is demo text" property color backgroundColor + property var horizontalAlignment + property var verticalAlignment //these properties are for giving video info to parents property int mpvPosition: mpv.position @@ -97,9 +99,10 @@ Item { /* minimumPointSize: 5 */ fontSizeMode: Text.Fit font.family: chosenFont + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter style: Text.Raised - anchors.centerIn: parent - /* width: parent.width */ + anchors.fill: parent clip: true layer.enabled: true diff --git a/src/serviceitemmodel.cpp b/src/serviceitemmodel.cpp index 3d1d196..8fb4a64 100644 --- a/src/serviceitemmodel.cpp +++ b/src/serviceitemmodel.cpp @@ -121,7 +121,7 @@ void ServiceItemModel::addItem(ServiceItem *item) { } void ServiceItemModel::insertItem(const int &index, ServiceItem *item) { - beginInsertRows(this->index(index), index, index); + beginInsertRows(this->index(index).parent(), index, index); m_items.insert(index, item); endInsertRows(); qDebug() << "Success"; @@ -164,7 +164,7 @@ void ServiceItemModel::insertItem(const int &index, const QString &name, const Q const QStringList &text) { ServiceItem *item = new ServiceItem(name, type, background, backgroundType, text); insertItem(index, item); - qDebug() << name << type << background; + qDebug() << name << type << background << text; } void ServiceItemModel::removeItem(int index) { @@ -188,3 +188,20 @@ bool ServiceItemModel::move(int sourceIndex, int destIndex) { // qDebug() << success; return true; } + +QVariantMap ServiceItemModel::getItem(int index) const { + QVariantMap data; + const QModelIndex idx = this->index(index,0); + qDebug() << idx; + if( !idx.isValid() ) + return data; + const QHash rn = roleNames(); + qDebug() << rn; + QHashIterator it(rn); + while (it.hasNext()) { + it.next(); + qDebug() << it.key() << ":" << it.value(); + data[it.value()] = idx.data(it.key()); + } + return data; +} diff --git a/src/serviceitemmodel.h b/src/serviceitemmodel.h index 7ec670d..4536b2c 100644 --- a/src/serviceitemmodel.h +++ b/src/serviceitemmodel.h @@ -56,6 +56,7 @@ public: const QString &backgroundType, const QStringList &text); Q_INVOKABLE void removeItem(int index); Q_INVOKABLE bool move(int sourceIndex, int destIndex); + Q_INVOKABLE QVariantMap getItem(int index) const; private: QList m_items;