adding backbones for audio

This commit is contained in:
Chris Cochrun 2022-09-25 07:08:00 -05:00
parent 9a732e6826
commit c197277e62
7 changed files with 86 additions and 16 deletions

View file

@ -402,13 +402,13 @@ ColumnLayout {
} }
function addItem(index, name, type, function addItem(index, name, type,
background, backgroundType, text, itemID) { background, backgroundType, text, audio, itemID) {
if (type === "song") { if (type === "song") {
const newtext = songsqlmodel.getLyricList(itemID); const newtext = songsqlmodel.getLyricList(itemID);
print("adding: " + name + " of type " + type); print("adding: " + name + " of type " + type);
serviceItemModel.insertItem(index, name, serviceItemModel.insertItem(index, name,
type, background, type, background,
backgroundType, newtext); backgroundType, audio, newtext);
totalServiceItems++; totalServiceItems++;
return; return;
} }
@ -419,7 +419,7 @@ ColumnLayout {
totalServiceItems++; totalServiceItems++;
} }
function appendItem(name, type, background, backgroundType, text, itemID) { function appendItem(name, type, background, backgroundType, text, audio, itemID) {
print("adding: " + name + " of type " + type); print("adding: " + name + " of type " + type);
let lyrics; let lyrics;
if (type === "song") { if (type === "song") {
@ -428,7 +428,7 @@ ColumnLayout {
lyrics = songsqlmodel.getLyricList(itemID); lyrics = songsqlmodel.getLyricList(itemID);
print(lyrics); print(lyrics);
serviceItemModel.addItem(name, type, background, serviceItemModel.addItem(name, type, background,
backgroundType, lyrics); backgroundType, lyrics, audio);
totalServiceItems++; totalServiceItems++;
return; return;
}; };

View file

@ -19,6 +19,7 @@ Item {
property bool dropShadow: false property bool dropShadow: false
property url imageSource property url imageSource
property url videoSource property url videoSource
property url audioSource
property int pdfIndex property int pdfIndex
property string chosenFont: "Quicksand" property string chosenFont: "Quicksand"
property string text: "This is demo text" property string text: "This is demo text"
@ -69,13 +70,11 @@ Item {
cursorShape: preview ? Qt.ArrowCursor : Qt.BlankCursor cursorShape: preview ? Qt.ArrowCursor : Qt.BlankCursor
} }
/* Controls.ProgressBar { */ MpvObject {
/* anchors.top: parent.bottom */ id: audio
/* width: mpv.width */ onFileLoaded: {}
/* visible: editMode */ }
/* value: mpv.position */
/* to: mpv.duration */
/* } */
} }
Timer { Timer {
@ -88,6 +87,7 @@ Item {
print("WHY AREN'T YOU PASUING!"); print("WHY AREN'T YOU PASUING!");
pauseTimer.restart(); pauseTimer.restart();
} }
audio.loadFile()
blackTimer.restart(); blackTimer.restart();
} }
} }

View file

@ -21,13 +21,23 @@ 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, QObject *parent) const QString &backgroundType, const QStringList &text,
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_backgroundType(backgroundType),m_text(text)
{ {
} }
ServiceItem::ServiceItem(const QString &name, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text,
const QString &audio, QObject *parent)
: QObject(parent),m_name(name),m_type(type),m_background(background),
m_backgroundType(backgroundType),m_text(text),m_audio(audio)
{
}
QString ServiceItem::name() const { QString ServiceItem::name() const {
return m_name; return m_name;
} }
@ -51,6 +61,10 @@ QStringList ServiceItem::text() const
return m_text; return m_text;
} }
QString ServiceItem::audio() const {
return m_audio;
}
void ServiceItem::setName(QString name) void ServiceItem::setName(QString name)
{ {
if (m_name == name) if (m_name == name)
@ -96,3 +110,12 @@ void ServiceItem::setText(QStringList text)
emit textChanged(m_text); emit textChanged(m_text);
} }
void ServiceItem::setAudio(QString audio)
{
if (m_audio == audio)
return;
m_audio = audio;
emit audioChanged(m_audio);
}

View file

@ -12,6 +12,7 @@ class ServiceItem : public QObject
Q_PROPERTY(QString background READ background WRITE setBackground NOTIFY backgroundChanged) Q_PROPERTY(QString background READ background WRITE setBackground NOTIFY backgroundChanged)
Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged) Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged)
Q_PROPERTY(QStringList text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QStringList text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged)
public: public:
explicit ServiceItem(QObject *parent = nullptr); explicit ServiceItem(QObject *parent = nullptr);
@ -19,19 +20,25 @@ public:
ServiceItem(const QString &name, const QString &type, const QString &background, ServiceItem(const QString &name, const QString &type, const QString &background,
const QString &backgroundType, QObject * parent = nullptr); const QString &backgroundType, QObject * parent = nullptr);
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, QObject * parent = nullptr); const QString &backgroundType, const QStringList &text,
QObject * parent = nullptr);
ServiceItem(const QString &name, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text, const QString &audio,
QObject * parent = nullptr);
QString name() const; QString name() const;
QString type() const; QString type() const;
QString background() const; QString background() const;
QString backgroundType() const; QString backgroundType() const;
QStringList text() const; QStringList text() const;
QString audio() const;
void setName(QString name); void setName(QString name);
void setType(QString type); void setType(QString type);
void setBackground(QString background); void setBackground(QString background);
void setBackgroundType(QString backgroundType); void setBackgroundType(QString backgroundType);
void setText(QStringList text); void setText(QStringList text);
void setAudio(QString audio);
signals: signals:
void nameChanged(QString name); void nameChanged(QString name);
@ -39,6 +46,7 @@ signals:
void backgroundChanged(QString background); void backgroundChanged(QString background);
void backgroundTypeChanged(QString backgroundType); void backgroundTypeChanged(QString backgroundType);
void textChanged(QStringList text); void textChanged(QStringList text);
void audioChanged(QString audio);
private: private:
QString m_name; QString m_name;
@ -46,6 +54,7 @@ private:
QString m_background; QString m_background;
QString m_backgroundType; QString m_backgroundType;
QStringList m_text; QStringList m_text;
QString m_audio;
}; };
#endif // SERVICEITEM_H #endif // SERVICEITEM_H

View file

@ -10,7 +10,7 @@ ServiceItemModel::ServiceItemModel(QObject *parent)
: QAbstractListModel(parent) { : QAbstractListModel(parent) {
addItem(new ServiceItem("10,000 Reasons", "song", addItem(new ServiceItem("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg", "file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"))); "image", "file:/home/chris/nextcloud/tfc/openlp/music/Eden-Phil Wickham [lyrics].mp3" QStringList("Yip Yip")));
addItem(new ServiceItem("Marvelous Light", "song", addItem(new ServiceItem("Marvelous Light", "song",
"file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4", "file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4",
"video", QStringList("Hallelujah!"))); "video", QStringList("Hallelujah!")));
@ -46,6 +46,8 @@ QVariant ServiceItemModel::data(const QModelIndex &index, int role) const {
return item->backgroundType(); return item->backgroundType();
case TextRole: case TextRole:
return item->text(); return item->text();
case AudioRole:
return item->audio();
default: default:
return QVariant(); return QVariant();
} }
@ -56,7 +58,8 @@ QHash<int, QByteArray> ServiceItemModel::roleNames() const {
{TypeRole, "type"}, {TypeRole, "type"},
{BackgroundRole, "background"}, {BackgroundRole, "background"},
{BackgroundTypeRole, "backgroundType"}, {BackgroundTypeRole, "backgroundType"},
{TextRole, "text"}}; {TextRole, "text"},
{AudioRole, "audio"}};
return mapping; return mapping;
} }
@ -98,6 +101,12 @@ bool ServiceItemModel::setData(const QModelIndex &index, const QVariant &value,
somethingChanged = true; somethingChanged = true;
} }
break; break;
case AudioRole:
if (item->audio() != value.toStringList()) {
item->setAudio(value.toStringList());
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;
@ -168,6 +177,15 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
qDebug() << name << type << background; qDebug() << name << type << background;
} }
void ServiceItemModel::addItem(const QString &name, const QString &type,
const QString &background, const QString &backgroundType,
const QStringList &text, const QString &audio) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio);
addItem(item);
qDebug() << name << type << background;
}
void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type) { void ServiceItemModel::insertItem(const int &index, const QString &name, const QString &type) {
ServiceItem *item = new ServiceItem(name, type); ServiceItem *item = new ServiceItem(name, type);
insertItem(index, item); insertItem(index, item);
@ -189,6 +207,16 @@ void ServiceItemModel::insertItem(const int &index, const QString &name, const Q
qDebug() << name << type << background << text; qDebug() << name << type << background << text;
} }
void ServiceItemModel::insertItem(const int &index, const QString &name,
const QString &type,const QString &background,
const QString &backgroundType,const QStringList &text,
const QString &audio) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio);
insertItem(index, item);
qDebug() << name << type << background << text;
}
void ServiceItemModel::removeItem(int index) { void ServiceItemModel::removeItem(int index) {
beginRemoveRows(QModelIndex(), index, index); beginRemoveRows(QModelIndex(), index, index);
m_items.removeAt(index); m_items.removeAt(index);

View file

@ -19,7 +19,8 @@ public:
TypeRole, TypeRole,
BackgroundRole, BackgroundRole,
BackgroundTypeRole, BackgroundTypeRole,
TextRole TextRole,
AudioRole
}; };
// Basic functionality: // Basic functionality:
@ -51,6 +52,10 @@ public:
const QString &background, const QString &background,
const QString &backgroundType, const QString &backgroundType,
const QStringList &text); const QStringList &text);
Q_INVOKABLE void addItem(const QString &name, const QString &type,
const QString &background,
const QString &backgroundType,
const QStringList &text, const QString &audio);
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,
@ -59,6 +64,10 @@ public:
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 &background, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text); const QString &backgroundType, const QStringList &text);
Q_INVOKABLE void insertItem(const int &index, const QString &name,
const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text,
const QString &audio);
Q_INVOKABLE void removeItem(int index); Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE bool move(int sourceIndex, int destIndex); Q_INVOKABLE bool move(int sourceIndex, int destIndex);
Q_INVOKABLE bool moveDown(int index); Q_INVOKABLE bool moveDown(int index);

View file

@ -252,6 +252,7 @@ void Slide::changeSlide(QVariantMap item)
m_slideSize = text.length(); m_slideSize = text.length();
m_slideIndex = 1; m_slideIndex = 1;
setText(text[0]); setText(text[0]);
setAudio(serviceItem().value("audio").toString());
} }
qDebug() << "MAP: " << m_serviceItem.value("text"); qDebug() << "MAP: " << m_serviceItem.value("text");