making preview of slides aware of being active and set first item

This commit is contained in:
Chris Cochrun 2022-09-28 09:51:47 -05:00
parent 56086dfe74
commit ace9da585a
4 changed files with 78 additions and 17 deletions

View file

@ -41,7 +41,7 @@ Controls.Page {
property string editType property string editType
Component.onCompleted: refocusTimer.start() Component.onCompleted: {refocusTimer.start(); changeServiceItem(0);}
Item { Item {
id: mainItem id: mainItem
anchors.fill: parent anchors.fill: parent
@ -160,6 +160,7 @@ Controls.Page {
/* presentation.itemType = item.type; */ /* presentation.itemType = item.type; */
print("Time to start changing"); print("Time to start changing");
serviceItemModel.activate(index);
SlideObject.changeSlide(item); SlideObject.changeSlide(item);
/* if (item.backgroundType === "video") */ /* if (item.backgroundType === "video") */
@ -168,6 +169,7 @@ Controls.Page {
/* } */ /* } */
presentation.textIndex = 0; presentation.textIndex = 0;
serviceItemModel.select(index);
/* presentation.changeSlide(); */ /* presentation.changeSlide(); */
print("Slide changed to: " + item.name); print("Slide changed to: " + item.name);

View file

@ -158,24 +158,56 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
Layout.columnSpan: 3 Layout.columnSpan: 3
orientation: ListView.Horizontal orientation: ListView.Horizontal
cacheBuffer: 900
reuseItems: true
model: serviceItemModel model: serviceItemModel
delegate: Presenter.Slide { delegate: Rectangle {
id: previewSlide id: previewHighlight
implicitWidth: 200 implicitWidth: 210
implicitHeight: width / 16 * 9 implicitHeight: width / 16 * 9
/* Layout.alignment: Qt.AlignCenter */ color: active ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
textSize: width / 15
itemType: root.itemType Presenter.Slide {
imageSource: background id: previewSlideItem
videoSource: background anchors.centerIn: parent
audioSource: audio implicitWidth: 200
chosenFont: font implicitHeight: width / 16 * 9
text: text textSize: width / 15
pdfIndex: 0 itemType: type
preview: true imageSource: backgroundType === "image" ? background : ""
editMode: true videoSource: backgroundType === "video" ? background : ""
audioSource: ""
chosenFont: font
text: text
pdfIndex: 0
preview: true
editMode: true
}
Controls.Label {
id: slidesTitle
width: previewSlideItem.width
anchors.top: previewSlideItem.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 5
elide: Text.ElideRight
text: name
/* font.family: "Quicksand Bold" */
}
} }
Kirigami.WheelHandler {
id: wheelHandler
target: previewSlidesList
filterMouseEvents: true
}
}
Item {
/* Layout.preferredHeight: 200 */
Layout.fillHeight: true
Layout.fillWidth: true
Layout.columnSpan: 3
} }
} }
@ -204,12 +236,12 @@ Item {
} }
function loadVideo() { function loadVideo() {
showPassiveNotification("Loading Video " + vidbackground) /* showPassiveNotification("Loading Video " + vidbackground) */
previewSlide.loadVideo(); previewSlide.loadVideo();
} }
function stopVideo() { function stopVideo() {
showPassiveNotification("Stopping Video") /* showPassiveNotification("Stopping Video") */
previewSlide.stopVideo() previewSlide.stopVideo()
} }
@ -225,6 +257,7 @@ Item {
print(changed); print(changed);
if (changed) { if (changed) {
currentServiceItem++; currentServiceItem++;
changeServiceItem(currentServiceItem);
leftDock.changeItem(); leftDock.changeItem();
} }
} }
@ -247,6 +280,7 @@ Item {
print(changed); print(changed);
if (changed) { if (changed) {
currentServiceItem--; currentServiceItem--;
changeServiceItem(currentServiceItem);
leftDock.changeItem(); leftDock.changeItem();
} }
} }

View file

@ -381,3 +381,27 @@ bool ServiceItemModel::select(int id) {
qDebug() << "################"; qDebug() << "################";
return true; return true;
} }
bool ServiceItemModel::activate(int id) {
QModelIndex idx = index(id);
ServiceItem *item = m_items[idx.row()];
for (int i = 0; i < m_items.length(); i++) {
QModelIndex idx = index(i);
ServiceItem *itm = m_items[idx.row()];
if (itm->active()) {
itm->setActive(false);
qDebug() << "################";
qDebug() << "deactivated" << itm->name();
qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << ActiveRole);
}
}
item->setActive(true);
qDebug() << "################";
qDebug() << "activated" << item->name();
qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << ActiveRole);
return true;
}

View file

@ -86,6 +86,7 @@ public:
Q_INVOKABLE bool moveDown(int index); Q_INVOKABLE bool moveDown(int index);
Q_INVOKABLE bool moveUp(int index); Q_INVOKABLE bool moveUp(int index);
Q_INVOKABLE bool select(int id); Q_INVOKABLE bool select(int id);
Q_INVOKABLE bool activate(int id);
Q_INVOKABLE QVariantMap getItem(int index) const; Q_INVOKABLE QVariantMap getItem(int index) const;
private: private: