add looping for slides

This add looping primarily for videos but I've added in the groundwork
for looping through any kind of slide. This obviously will be
implemented differently for each type of slide, but this way the
groundwork is done already.
This commit is contained in:
Chris Cochrun 2023-03-06 15:06:18 -06:00
parent caded1027c
commit caa2e31d99
15 changed files with 130 additions and 49 deletions

View file

@ -52,9 +52,9 @@ ServiceItem::ServiceItem(const QString &name, const QString &type, const QString
ServiceItem::ServiceItem(const QString &name, const QString &type, const QString &background, ServiceItem::ServiceItem(const QString &name, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text, const QString &backgroundType, const QStringList &text,
const QString &audio, const QString &font, const int &fontSize, const QString &audio, const QString &font, const int &fontSize,
const int &slideNumber, QObject *parent) const int &slideNumber, const bool &loop, QObject *parent)
: QObject(parent),m_name(name),m_type(type),m_background(background), : QObject(parent),m_name(name),m_type(type),m_background(background),
m_backgroundType(backgroundType),m_text(text),m_audio(audio),m_font(font),m_fontSize(fontSize),m_slideNumber(slideNumber) m_backgroundType(backgroundType),m_text(text),m_audio(audio),m_font(font),m_fontSize(fontSize),m_slideNumber(slideNumber),m_loop(loop)
{ {
} }
@ -106,6 +106,10 @@ bool ServiceItem::selected() const {
return m_selected; return m_selected;
} }
bool ServiceItem::loop() const {
return m_loop;
}
void ServiceItem::setName(QString name) void ServiceItem::setName(QString name)
{ {
if (m_name == name) if (m_name == name)
@ -207,3 +211,12 @@ void ServiceItem::setSelected(bool selected)
m_selected = selected; m_selected = selected;
emit selectedChanged(m_selected); emit selectedChanged(m_selected);
} }
void ServiceItem::setLoop(bool loop)
{
if (m_loop == loop)
return;
m_loop = loop;
emit loopChanged(m_loop);
}

View file

@ -18,6 +18,7 @@ class ServiceItem : public QObject
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged) Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY(bool loop READ loop WRITE setLoop NOTIFY loopChanged)
Q_PROPERTY(int slideNumber READ slideNumber WRITE setSlideNumber NOTIFY slideNumberChanged) Q_PROPERTY(int slideNumber READ slideNumber WRITE setSlideNumber NOTIFY slideNumberChanged)
// Q_PROPERTY(Thumbnail thumbnail READ thumbnail WRITE setThumbnail NOTIFY thumbnailChanged) // Q_PROPERTY(Thumbnail thumbnail READ thumbnail WRITE setThumbnail NOTIFY thumbnailChanged)
@ -38,7 +39,7 @@ public:
ServiceItem(const QString &name, const QString &type, const QString &background, ServiceItem(const QString &name, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text, const QString &audio, const QString &backgroundType, const QStringList &text, const QString &audio,
const QString &font, const int &fontSize, const int &slideNumber, const QString &font, const int &fontSize, const int &slideNumber,
QObject * parent = nullptr); const bool &loop, QObject * parent = nullptr);
QString name() const; QString name() const;
QString type() const; QString type() const;
@ -50,6 +51,7 @@ public:
int fontSize() const; int fontSize() const;
bool active() const; bool active() const;
bool selected() const; bool selected() const;
bool loop() const;
int slideNumber() const; int slideNumber() const;
// Thumbnail thumbnail() const; // Thumbnail thumbnail() const;
@ -64,6 +66,7 @@ public:
void setSlideNumber(int slideNumber); void setSlideNumber(int slideNumber);
void setActive(bool active); void setActive(bool active);
void setSelected(bool selected); void setSelected(bool selected);
void setLoop(bool loop);
signals: signals:
void nameChanged(QString name); void nameChanged(QString name);
@ -77,6 +80,7 @@ signals:
void slideNumberChanged(int slideNumber); void slideNumberChanged(int slideNumber);
void activeChanged(bool active); void activeChanged(bool active);
void selectedChanged(bool selected); void selectedChanged(bool selected);
void loopChanged(bool loop);
private: private:
QString m_name; QString m_name;
@ -90,6 +94,7 @@ private:
int m_slideNumber; int m_slideNumber;
bool m_active; bool m_active;
bool m_selected; bool m_selected;
bool m_loop;
}; };
#endif // SERVICEITEM_H #endif // SERVICEITEM_H

View file

@ -68,6 +68,8 @@ QVariant ServiceItemModel::data(const QModelIndex &index, int role) const {
return item->active(); return item->active();
case SelectedRole: case SelectedRole:
return item->selected(); return item->selected();
case LoopRole:
return item->loop();
default: default:
return QVariant(); return QVariant();
} }
@ -84,7 +86,8 @@ QHash<int, QByteArray> ServiceItemModel::roleNames() const {
{FontSizeRole, "fontSize"}, {FontSizeRole, "fontSize"},
{SlideNumberRole, "slideNumber"}, {SlideNumberRole, "slideNumber"},
{ActiveRole, "active"}, {ActiveRole, "active"},
{SelectedRole, "selected"}}; {SelectedRole, "selected"},
{LoopRole, "loop"}};
return mapping; return mapping;
} }
@ -162,6 +165,12 @@ bool ServiceItemModel::setData(const QModelIndex &index, const QVariant &value,
somethingChanged = true; somethingChanged = true;
} }
break; break;
case LoopRole:
if (item->loop() != value.toBool()) {
item->setLoop(value.toBool());
somethingChanged = true;
}
break;
if (somethingChanged) { if (somethingChanged) {
emit dataChanged(index, index, QVector<int>() << role); emit dataChanged(index, index, QVector<int>() << role);
return true; return true;
@ -267,12 +276,12 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
const QString &background, const QString &backgroundType, const QString &background, const QString &backgroundType,
const QStringList &text, const QString &audio, const QStringList &text, const QString &audio,
const QString &font, const int &fontSize, const QString &font, const int &fontSize,
const int &slideNumber) { const int &slideNumber, const bool &loop) {
qDebug() << "*************************"; qDebug() << "*************************";
qDebug() << "Plain adding item: " << name; qDebug() << "Plain adding item: " << name;
qDebug() << "*************************"; qDebug() << "*************************";
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio, font, fontSize, slideNumber); text, audio, font, fontSize, slideNumber, loop);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
addItem(item); addItem(item);
@ -339,12 +348,13 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
const QString &type,const QString &background, const QString &type,const QString &background,
const QString &backgroundType,const QStringList &text, const QString &backgroundType,const QStringList &text,
const QString &audio, const QString &font, const QString &audio, const QString &font,
const int &fontSize, const int &slideNumber) { const int &fontSize, const int &slideNumber,
const bool &loop) {
qDebug() << "*************************"; qDebug() << "*************************";
qDebug() << "Inserting serviceItem: " << name << " and index is " << index; qDebug() << "Inserting serviceItem: " << name << " and index is " << index;
qDebug() << "*************************"; qDebug() << "*************************";
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio, font, fontSize, slideNumber); text, audio, font, fontSize, slideNumber, loop);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
insertItem(index, item); insertItem(index, item);
@ -490,6 +500,7 @@ QVariantList ServiceItemModel::getItems() {
itm["fontSize"] = item->fontSize(); itm["fontSize"] = item->fontSize();
itm["slideNumber"] = item->slideNumber(); itm["slideNumber"] = item->slideNumber();
itm["selected"] = item->selected(); itm["selected"] = item->selected();
itm["loop"] = item->loop();
itm["active"] = item->active(); itm["active"] = item->active();
data.append(itm); data.append(itm);
} }
@ -614,6 +625,7 @@ bool ServiceItemModel::save(QUrl file) {
item.insert("slideNumber", m_items[i]->slideNumber()); item.insert("slideNumber", m_items[i]->slideNumber());
item.insert("text", m_items[i]->text()); item.insert("text", m_items[i]->text());
item.insert("type", m_items[i]->type()); item.insert("type", m_items[i]->type());
item.insert("loop", m_items[i]->loop());
qDebug() << "AUDIO IS: " << item.value("audio").toString(); qDebug() << "AUDIO IS: " << item.value("audio").toString();
QFileInfo audioFile = item.value("audio").toString(); QFileInfo audioFile = item.value("audio").toString();
@ -807,11 +819,11 @@ bool ServiceItemModel::load(QUrl file) {
} }
addItem(item.value("name").toString(), item.value("type").toString(), addItem(item.value("name").toString(), item.value("type").toString(),
realBackground, realBackground,
item.value("backgroundType").toString(), item.value("backgroundType").toString(),
item.value("text").toStringList(), realAudio, item.value("text").toStringList(), realAudio,
item.value("font").toString(), item.value("fontSize").toInt(), item.value("font").toString(), item.value("fontSize").toInt(),
item.value("slideNumber").toInt()); item.value("slideNumber").toInt(), item.value("loop").toBool());
} }
return true; return true;

View file

@ -26,7 +26,8 @@ public:
FontSizeRole, FontSizeRole,
SlideNumberRole, SlideNumberRole,
ActiveRole, ActiveRole,
SelectedRole SelectedRole,
LoopRole
}; };
// Basic functionality: // Basic functionality:
@ -72,7 +73,7 @@ public:
const QString &backgroundType, const QString &backgroundType,
const QStringList &text, const QString &audio, const QStringList &text, const QString &audio,
const QString &font, const int &fontSize, const QString &font, const int &fontSize,
const int &slideNumber); const int &slideNumber, const bool &loop);
// Q_INVOKABLE void insertItem(const int &index, const QString &name, // Q_INVOKABLE void insertItem(const int &index, const QString &name,
// const QString &type); // const QString &type);
// Q_INVOKABLE void insertItem(const int &index, const QString &name, // Q_INVOKABLE void insertItem(const int &index, const QString &name,
@ -93,7 +94,8 @@ public:
const QString &type, const QString &background, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text, const QString &backgroundType, const QStringList &text,
const QString &audio, const QString &font, const QString &audio, const QString &font,
const int &fontSize, const int &slideNumber); const int &fontSize, const int &slideNumber,
const bool &loop);
Q_INVOKABLE void removeItem(int index); Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE void removeItems(); Q_INVOKABLE void removeItems();
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count); Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);

View file

@ -13,12 +13,12 @@ Slide::Slide(const QString &text, const QString &audio, const QString &imageBack
const QString &videoBackground, const QString &horizontalTextAlignment, const QString &videoBackground, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &font, const QString &verticalTextAlignment, const QString &font,
const int &fontSize, const int &imageCount, const int &fontSize, const int &imageCount,
const QString &type, const int &slideIndex, QObject *parent) const QString &type, const int &slideIndex, const bool &loop, QObject *parent)
: QObject(parent),m_text(text),m_audio(audio),m_imageBackground(imageBackground), : QObject(parent),m_text(text),m_audio(audio),m_imageBackground(imageBackground),
m_videoBackground(videoBackground),m_verticalTextAlignment(verticalTextAlignment), m_videoBackground(videoBackground),m_verticalTextAlignment(verticalTextAlignment),
m_horizontalTextAlignment(horizontalTextAlignment),m_font(font), m_horizontalTextAlignment(horizontalTextAlignment),m_font(font),
m_fontSize(fontSize),m_imageCount(imageCount),m_type(type), m_fontSize(fontSize),m_imageCount(imageCount),m_type(type),
m_slideIndex(slideIndex),m_active(false),m_selected(false) m_slideIndex(slideIndex),m_active(false),m_selected(false),m_loop(loop)
{ {
qDebug() << "Initializing slide with defaults"; qDebug() << "Initializing slide with defaults";
} }
@ -92,6 +92,10 @@ bool Slide::selected() const {
return m_selected; return m_selected;
} }
bool Slide::loop() const {
return m_loop;
}
void Slide::setText(QString text) void Slide::setText(QString text)
{ {
if (m_text == text) if (m_text == text)
@ -238,3 +242,12 @@ void Slide::setSelected(bool selected)
m_selected = selected; m_selected = selected;
emit selectedChanged(m_selected); emit selectedChanged(m_selected);
} }
void Slide::setLoop(bool loop)
{
if (m_loop == loop)
return;
m_loop = loop;
emit loopChanged(m_loop);
}

View file

@ -28,6 +28,7 @@ class Slide : public QObject
Q_PROPERTY(int slideIndex READ slideIndex WRITE setSlideIndex NOTIFY slideIndexChanged) Q_PROPERTY(int slideIndex READ slideIndex WRITE setSlideIndex NOTIFY slideIndexChanged)
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged) Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY(bool loop READ loop WRITE setLoop NOTIFY loopChanged)
Q_PROPERTY(QString vidThumbnail READ vidThumbnail WRITE setVidThumbnail Q_PROPERTY(QString vidThumbnail READ vidThumbnail WRITE setVidThumbnail
NOTIFY vidThumbnailChanged) NOTIFY vidThumbnailChanged)
// QML_ELEMENT // QML_ELEMENT
@ -38,7 +39,7 @@ public:
const QString &imageBackground, const QString &videoBackground, const QString &imageBackground, const QString &videoBackground,
const QString &horizontalTextAlignment, const QString &verticalTextAlignment, const QString &horizontalTextAlignment, const QString &verticalTextAlignment,
const QString &font, const int &fontSize, const int &imageCount, const QString &font, const int &fontSize, const int &imageCount,
const QString &type, const int &slideIndex, const QString &type, const int &slideIndex, const bool &loop,
QObject * parent = nullptr); QObject * parent = nullptr);
QString text() const; QString text() const;
@ -55,6 +56,7 @@ public:
int serviceItemId() const; int serviceItemId() const;
bool active() const; bool active() const;
bool selected() const; bool selected() const;
bool loop() const;
QString vidThumbnail() const; QString vidThumbnail() const;
Q_INVOKABLE void setText(QString text); Q_INVOKABLE void setText(QString text);
@ -71,6 +73,7 @@ public:
Q_INVOKABLE void setSlideIndex(int slideIndex); Q_INVOKABLE void setSlideIndex(int slideIndex);
Q_INVOKABLE void setActive(bool active); Q_INVOKABLE void setActive(bool active);
Q_INVOKABLE void setSelected(bool selected); Q_INVOKABLE void setSelected(bool selected);
Q_INVOKABLE void setLoop(bool loop);
Q_INVOKABLE void setVidThumbnail(QString vidThumbnail); Q_INVOKABLE void setVidThumbnail(QString vidThumbnail);
signals: signals:
@ -88,6 +91,7 @@ signals:
Q_INVOKABLE void slideIndexChanged(int slideIndex); Q_INVOKABLE void slideIndexChanged(int slideIndex);
Q_INVOKABLE void activeChanged(bool active); Q_INVOKABLE void activeChanged(bool active);
Q_INVOKABLE void selectedChanged(bool selected); Q_INVOKABLE void selectedChanged(bool selected);
Q_INVOKABLE void loopChanged(bool loop);
Q_INVOKABLE void vidThumbnailChanged(QString vidThumbnail); Q_INVOKABLE void vidThumbnailChanged(QString vidThumbnail);
private: private:
@ -106,6 +110,7 @@ private:
int m_slideIndex; int m_slideIndex;
bool m_active; bool m_active;
bool m_selected; bool m_selected;
bool m_loop;
QString m_vidThumbnail; QString m_vidThumbnail;
}; };

View file

@ -85,6 +85,8 @@ QVariant SlideModel::data(const QModelIndex &index, int role) const {
return item->active(); return item->active();
case SelectedRole: case SelectedRole:
return item->selected(); return item->selected();
case LoopRole:
return item->loop();
case VidThumbnailRole: case VidThumbnailRole:
return item->vidThumbnail(); return item->vidThumbnail();
default: default:
@ -107,6 +109,7 @@ QHash<int, QByteArray> SlideModel::roleNames() const {
{SlideIndexRole, "slideIndex"}, {SlideIndexRole, "slideIndex"},
{ActiveRole, "active"}, {ActiveRole, "active"},
{SelectedRole, "selected"}, {SelectedRole, "selected"},
{LoopRole, "loop"},
{VidThumbnailRole, "vidThumbnail"} {VidThumbnailRole, "vidThumbnail"}
}; };
@ -198,6 +201,12 @@ bool SlideModel::setData(const QModelIndex &index, const QVariant &value,
somethingChanged = true; somethingChanged = true;
} }
break; break;
case LoopRole:
if (item->loop() != value.toBool()) {
item->setLoop(value.toBool());
somethingChanged = true;
}
break;
case VidThumbnailRole: case VidThumbnailRole:
if (item->vidThumbnail() != value.toString()) { if (item->vidThumbnail() != value.toString()) {
item->setVidThumbnail(value.toString()); item->setVidThumbnail(value.toString());
@ -262,11 +271,11 @@ void SlideModel::addItem(const QString &text, const QString &type,
const QString &horizontalTextAlignment, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId, const int &slideIndex, const int &serviceItemId, const int &slideIndex,
const int &imageCount) { const int &imageCount, const bool &loop) {
Slide *item = new Slide(text, audio, imageBackground, videoBackground, Slide *item = new Slide(text, audio, imageBackground, videoBackground,
horizontalTextAlignment, horizontalTextAlignment,
verticalTextAlignment, verticalTextAlignment,
font, fontSize, imageCount, type, slideIndex ); font, fontSize, imageCount, type, slideIndex, loop);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
item->setServiceItemId(serviceItemId); item->setServiceItemId(serviceItemId);
@ -283,10 +292,10 @@ void SlideModel::insertItem(const int &index,
const int &fontSize, const QString &horizontalTextAlignment, const int &fontSize, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId, const int &slideIndex, const int &serviceItemId, const int &slideIndex,
const int &imageCount) { const int &imageCount, const bool &loop) {
Slide *item = new Slide(text, audio, imageBackground, videoBackground, Slide *item = new Slide(text, audio, imageBackground, videoBackground,
horizontalTextAlignment, verticalTextAlignment, font, fontSize, horizontalTextAlignment, verticalTextAlignment, font, fontSize,
imageCount, type, slideIndex); imageCount, type, slideIndex, loop);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
item->setServiceItemId(serviceItemId); item->setServiceItemId(serviceItemId);
@ -461,6 +470,7 @@ QVariantList SlideModel::getItems() {
itm["serviceItemId"] = item->serviceItemId(); itm["serviceItemId"] = item->serviceItemId();
itm["selected"] = item->selected(); itm["selected"] = item->selected();
itm["active"] = item->active(); itm["active"] = item->active();
itm["loop"] = item->loop();
data.append(itm); data.append(itm);
} }
qDebug() << "$$$$$$$$$$$$$$$$$$$$$$$$$$$"; qDebug() << "$$$$$$$$$$$$$$$$$$$$$$$$$$$";
@ -552,11 +562,11 @@ void SlideModel::addItemFromService(const int &index, const ServiceItem &item) {
if (item.backgroundType() == "image") { if (item.backgroundType() == "image") {
addItem(item.text()[i], item.type(), item.background(), "", addItem(item.text()[i], item.type(), item.background(), "",
item.audio(), item.font(), item.fontSize(), "center", "center", item.audio(), item.font(), item.fontSize(), "center", "center",
index, i, item.text().size()); index, i, item.text().size(), item.loop());
} else { } else {
addItem(item.text()[i], item.type(), "", item.background(), addItem(item.text()[i], item.type(), "", item.background(),
item.audio(), item.font(), item.fontSize(), "center", "center", item.audio(), item.font(), item.fontSize(), "center", "center",
index, i, item.text().size()); index, i, item.text().size(), item.loop());
} }
} }
} else if (item.type() == "presentation") { } else if (item.type() == "presentation") {
@ -564,18 +574,18 @@ void SlideModel::addItemFromService(const int &index, const ServiceItem &item) {
addItem("", item.type(), item.background(), "", addItem("", item.type(), item.background(), "",
item.audio(), item.font(), item.fontSize(), item.audio(), item.font(), item.fontSize(),
"center", "center", "center", "center",
index, i, item.slideNumber()); index, i, item.slideNumber(), item.loop());
} }
} else if (item.type() == "video") { } else if (item.type() == "video") {
addItem("", item.type(), "", item.background(), addItem("", item.type(), "", item.background(),
item.audio(), item.font(), item.fontSize(), item.audio(), item.font(), item.fontSize(),
"center", "center", "center", "center",
index, 0, 1); index, 0, 1, item.loop());
} else { } else {
addItem("", item.type(), item.background(), "", addItem("", item.type(), item.background(), "",
item.audio(), item.font(), item.fontSize(), item.audio(), item.font(), item.fontSize(),
"center", "center", "center", "center",
index, 0, 1); index, 0, 1, item.loop());
} }
} }
@ -595,11 +605,11 @@ void SlideModel::insertItemFromService(const int &index, const ServiceItem &item
if (item.backgroundType() == "image") { if (item.backgroundType() == "image") {
insertItem(slideId + i, item.type(), item.background(), "", item.text()[i], insertItem(slideId + i, item.type(), item.background(), "", item.text()[i],
item.audio(), item.font(), item.fontSize(), "center", "center", item.audio(), item.font(), item.fontSize(), "center", "center",
index, i, item.text().size()); index, i, item.text().size(), item.loop());
} else { } else {
insertItem(slideId + i, item.type(), "", item.background(), item.text()[i], insertItem(slideId + i, item.type(), "", item.background(), item.text()[i],
item.audio(), item.font(), item.fontSize(), "center", "center", item.audio(), item.font(), item.fontSize(), "center", "center",
index, i, item.text().size()); index, i, item.text().size(), item.loop());
} }
} }
} else if (item.type() == "presentation") { } else if (item.type() == "presentation") {
@ -607,18 +617,18 @@ void SlideModel::insertItemFromService(const int &index, const ServiceItem &item
insertItem(slideId + i, item.type(), item.background(), "", insertItem(slideId + i, item.type(), item.background(), "",
"", item.audio(), item.font(), item.fontSize(), "", item.audio(), item.font(), item.fontSize(),
"center", "center", "center", "center",
index, i, item.slideNumber()); index, i, item.slideNumber(), item.loop());
} }
} else if (item.type() == "video") { } else if (item.type() == "video") {
insertItem(slideId, item.type(), "", item.background(), "", insertItem(slideId, item.type(), "", item.background(), "",
item.audio(), item.font(), item.fontSize(), item.audio(), item.font(), item.fontSize(),
"center", "center", "center", "center",
index, 0, 1); index, 0, 1, item.loop());
} else { } else {
insertItem(slideId, item.type(), item.background(), "", "", insertItem(slideId, item.type(), item.background(), "", "",
item.audio(), item.font(), item.fontSize(), item.audio(), item.font(), item.fontSize(),
"center", "center", "center", "center",
index, 0, 1); index, 0, 1, item.loop());
} }
} }

View file

@ -30,6 +30,7 @@ public:
ImageCountRole, ImageCountRole,
ActiveRole, ActiveRole,
SelectedRole, SelectedRole,
LoopRole,
VidThumbnailRole VidThumbnailRole
}; };
@ -61,7 +62,8 @@ public:
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId, const int &serviceItemId,
const int &slideIndex, const int &slideIndex,
const int &imageCount); const int &imageCount,
const bool &loop);
Q_INVOKABLE void insertItem(const int &index, const QString &text, Q_INVOKABLE void insertItem(const int &index, const QString &text,
const QString &type, const QString &imageBackground, const QString &type, const QString &imageBackground,
const QString &videoBackground, const QString &videoBackground,
@ -71,7 +73,8 @@ public:
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId, const int &serviceItemId,
const int &slideIndex, const int &slideIndex,
const int &imageCount); const int &imageCount,
const bool &loop);
Q_INVOKABLE void removeItem(int index); Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE void removeItems(); Q_INVOKABLE void removeItems();
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count); Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);

View file

@ -84,6 +84,10 @@ void SlideObject::changeSlide(QVariantMap item, int index)
if (item.value("fontSize").toInt() != fontSize()) if (item.value("fontSize").toInt() != fontSize())
setFontSize(item.value("fontSize").toInt()); setFontSize(item.value("fontSize").toInt());
if (loop() != item.value("loop").toBool()) {
setLoop(item.value("loop").toBool());
emit loopChanged(loop());
}
setImageCount(item.value("imageCount").toInt()); setImageCount(item.value("imageCount").toInt());
setSlideIndex(item.value("slideIndex").toInt()); setSlideIndex(item.value("slideIndex").toInt());
qDebug() << "THIS IS THE INDEX OF THE SLIDE!"; qDebug() << "THIS IS THE INDEX OF THE SLIDE!";
@ -108,6 +112,10 @@ bool SlideObject::next(QVariantMap nextItem, SlideModel *slideModel)
setFontSize(nextItem.value("fontSize").toInt()); setFontSize(nextItem.value("fontSize").toInt());
setImageCount(nextItem.value("imageCount").toInt()); setImageCount(nextItem.value("imageCount").toInt());
setSlideIndex(nextItem.value("slideIndex").toInt()); setSlideIndex(nextItem.value("slideIndex").toInt());
if (loop() != nextItem.value("loop").toBool()) {
setLoop(nextItem.value("loop").toBool());
emit loopChanged(loop());
}
// m_slideSize = serviceItem.value("slideNumber").toInt(); // m_slideSize = serviceItem.value("slideNumber").toInt();
@ -129,6 +137,10 @@ bool SlideObject::previous(QVariantMap prevItem, SlideModel *slideModel)
setFontSize(prevItem.value("fontSize").toInt()); setFontSize(prevItem.value("fontSize").toInt());
setImageCount(prevItem.value("imageCount").toInt()); setImageCount(prevItem.value("imageCount").toInt());
setSlideIndex(prevItem.value("slideIndex").toInt()); setSlideIndex(prevItem.value("slideIndex").toInt());
if (loop() != prevItem.value("loop").toBool()) {
setLoop(prevItem.value("loop").toBool());
emit loopChanged(loop());
}
// m_slideSize = serviceItem.value("slideNumber").toInt(); // m_slideSize = serviceItem.value("slideNumber").toInt();
// emit slideSizeChanged(m_slideSize); // emit slideSizeChanged(m_slideSize);
@ -173,9 +185,9 @@ void SlideObject::play()
emit isPlayingChanged(m_isPlaying); emit isPlayingChanged(m_isPlaying);
} }
void SlideObject::setLoop() void SlideObject::setLoop(bool loop)
{ {
m_loop = true; m_loop = loop;
emit loopChanged(m_loop); emit loopChanged(m_loop);
} }

View file

@ -39,7 +39,7 @@ public:
Q_INVOKABLE bool next(QVariantMap nextItem, SlideModel *slideModel); Q_INVOKABLE bool next(QVariantMap nextItem, SlideModel *slideModel);
Q_INVOKABLE bool previous(QVariantMap prevItem, SlideModel *slideModel); Q_INVOKABLE bool previous(QVariantMap prevItem, SlideModel *slideModel);
Q_INVOKABLE bool changeSlideIndex(int index); Q_INVOKABLE bool changeSlideIndex(int index);
Q_INVOKABLE void setLoop(); Q_INVOKABLE void setLoop(bool loop);
signals: signals:
Q_INVOKABLE void isPlayingChanged(bool isPlaying); Q_INVOKABLE void isPlayingChanged(bool isPlaying);

View file

@ -169,7 +169,7 @@ int main(int argc, char *argv[])
serviceItemModel.get()->addItem("Black", "image", serviceItemModel.get()->addItem("Black", "image",
"qrc:/assets/black.jpg", "qrc:/assets/black.jpg",
"image", QStringList(""), "image", QStringList(""),
"", "", 0, 1); "", "", 0, 1, false);
} }
// apparently mpv needs this class set // apparently mpv needs this class set

View file

@ -127,6 +127,7 @@ FocusScope {
chosenFont: SlideObject.font chosenFont: SlideObject.font
text: SlideObject.text text: SlideObject.text
pdfIndex: SlideObject.pdfIndex pdfIndex: SlideObject.pdfIndex
vidLoop: SlideObject.loop
preview: true preview: true
} }
@ -173,8 +174,8 @@ FocusScope {
Controls.Switch { Controls.Switch {
id: loopSwitch id: loopSwitch
text: "Loop" text: "Loop"
checked: previewSlide.mpvLoop === "inf" ? true : false checked: SlideObject.loop
onToggled: mainPage.loopVideo() onToggled: SlideObject.setLoop(!SlideObject.loop)
Keys.onLeftPressed: previousSlideAction() Keys.onLeftPressed: previousSlideAction()
Keys.onRightPressed: nextSlideAction() Keys.onRightPressed: nextSlideAction()
Keys.onUpPressed: previousSlideAction() Keys.onUpPressed: previousSlideAction()

View file

@ -42,6 +42,7 @@ Window {
textSize: SlideObject.fontSize textSize: SlideObject.fontSize
pdfIndex: SlideObject.pdfIndex pdfIndex: SlideObject.pdfIndex
itemType: SlideObject.type itemType: SlideObject.type
vidLoop: SlideObject.loop
} }
Connections { Connections {

View file

@ -534,7 +534,7 @@ Item {
ServiceItemModel.insertItem(index, image.title, ServiceItemModel.insertItem(index, image.title,
type, image.filePath, type, image.filePath,
"image", "", "", "image", "", "",
"", 0, 0); "", 0, 0, false);
return; return;
} }
case 'video': { case 'video': {
@ -543,7 +543,7 @@ Item {
ServiceItemModel.insertItem(index, video.title, ServiceItemModel.insertItem(index, video.title,
type, video.filePath, type, video.filePath,
"video", "", "", "video", "", "",
"", 0, 0); "", 0, 0, video.loop);
return; return;
} }
case 'song': { case 'song': {
@ -557,7 +557,7 @@ Item {
type, song.background, type, song.background,
song.backgroundType, lyrics, song.backgroundType, lyrics,
song.audio, song.font, song.fontSize, song.audio, song.font, song.fontSize,
lyrics.length); lyrics.length, true);
return; return;
} }
case 'presentation': { case 'presentation': {
@ -568,7 +568,7 @@ Item {
ServiceItemModel.insertItem(index, pres.title, ServiceItemModel.insertItem(index, pres.title,
type, pres.filePath, type, pres.filePath,
"image", "", "image", "",
"", "", 0, pres.pageCount); "", "", 0, pres.pageCount, false);
return; return;
} }
default: return; default: return;
@ -584,7 +584,7 @@ Item {
ServiceItemModel.addItem(image.title, ServiceItemModel.addItem(image.title,
type, image.filePath, type, image.filePath,
"image", "", "", "image", "", "",
"", 0, 0); "", 0, 0, false);
return; return;
} }
case 'video': { case 'video': {
@ -593,7 +593,7 @@ Item {
ServiceItemModel.addItem(video.title, ServiceItemModel.addItem(video.title,
type, video.filePath, type, video.filePath,
"video", "", "", "video", "", "",
"", 0, 0); "", 0, 0, video.loop);
return; return;
} }
case 'song': { case 'song': {
@ -605,7 +605,8 @@ Item {
ServiceItemModel.addItem(song.title, ServiceItemModel.addItem(song.title,
type, song.background, type, song.background,
song.backgroundType, lyrics, song.backgroundType, lyrics,
song.audio, song.font, song.fontSize, lyrics.length); song.audio, song.font, song.fontSize,
lyrics.length, true);
return; return;
} }
case 'presentation': { case 'presentation': {
@ -616,7 +617,8 @@ Item {
ServiceItemModel.addItem(pres.title, ServiceItemModel.addItem(pres.title,
type, pres.filePath, type, pres.filePath,
"image", "", "image", "",
"", "", 0, pres.pageCount); "", "", 0, pres.pageCount,
false);
return; return;
} }
default: return; default: return;

View file

@ -58,6 +58,8 @@ Item {
/* showPassiveNotification(videoSource + " has been loaded"); */ /* showPassiveNotification(videoSource + " has been loaded"); */
if (itemType == "song") if (itemType == "song")
mpv.setProperty("loop", "inf"); mpv.setProperty("loop", "inf");
else if (vidLoop)
mpv.setProperty("loop", "inf");
else else
mpv.setProperty("loop", "no"); mpv.setProperty("loop", "no");
/* showPassiveNotification(mpv.getProperty("loop")); */ /* showPassiveNotification(mpv.getProperty("loop")); */