moving more functions to slide class

This commit is contained in:
Chris Cochrun 2022-07-15 16:33:54 -05:00
parent dbc6b5e33a
commit 964eefb7de
4 changed files with 45 additions and 32 deletions

View file

@ -94,8 +94,7 @@ int main(int argc, char *argv[])
qDebug() << QIcon::themeName(); qDebug() << QIcon::themeName();
//Need to instantiate our slide //Need to instantiate our slide
ServiceItemModel services(); QScopedPointer<Slide> slide(new Slide);
QScopedPointer<Slide> slide(new Slide("", "", "", "", "", "", "", 0));
// apparently mpv needs this class set // apparently mpv needs this class set
// let's register mpv as well // let's register mpv as well

View file

@ -121,30 +121,17 @@ Controls.Page {
function changeServiceItem(index) { function changeServiceItem(index) {
const item = serviceItemModel.getItem(index); const item = serviceItemModel.getItem(index);
print("index grabbed: " + index); print("index grabbed: " + index);
print(item);
presentation.stopVideo() presentation.stopVideo()
presentation.itemType = item.type; presentation.itemType = item.type;
print("Time to start changing"); print("Time to start changing");
if (item.backgroundType === "image") { SlideObject.changeSlide(item);
print("The slides backgorund is: " + SlideObject.imageBackground);
SlideObject.setVideoBackground(""); if (item.backgroundType === "video")
SlideObject.setImageBackground(item.background); presentation.loadVideo();
} else {
print("The slides backgorund is: " + SlideObject.videoBackground);
SlideObject.setImageBackground("");
SlideObject.setVideoBackground(item.background);
presentation.loadVideo()
}
print("text length: " + item.text.length);
print("text: " + item.text);
if (item.text.length === 0) {
SlideObject.setText("");
}
else
SlideObject.setText(item.text[0]);
presentation.textIndex = 0; presentation.textIndex = 0;
presentation.changeSlide(); presentation.changeSlide();

View file

@ -12,10 +12,10 @@ Slide::Slide(QObject *parent)
Slide::Slide(const QString &text, const QString &audio, const QString &imageBackground, Slide::Slide(const QString &text, const QString &audio, const QString &imageBackground,
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, QObject *parent) const int &fontSize, const QString &type, 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_fontSize(fontSize) m_horizontalTextAlignment(horizontalTextAlignment),m_font(font),m_fontSize(fontSize),m_type(type)
{ {
qDebug() << "Initializing slide with defaults"; qDebug() << "Initializing slide with defaults";
qDebug() << m_imageBackground; qDebug() << m_imageBackground;
@ -25,6 +25,10 @@ QString Slide::text() const {
return m_text; return m_text;
} }
QString Slide::type() const {
return m_type;
}
QString Slide::audio() const { QString Slide::audio() const {
return m_audio; return m_audio;
} }
@ -69,6 +73,16 @@ void Slide::setText(QString text)
emit textChanged(m_text); emit textChanged(m_text);
} }
void Slide::setType(QString type)
{
qDebug() << "####changing type to: " << type;
if (m_type == type)
return;
m_type = type;
emit typeChanged(m_type);
}
void Slide::setAudio(QString audio) void Slide::setAudio(QString audio)
{ {
if (m_audio == audio) if (m_audio == audio)
@ -134,18 +148,26 @@ void Slide::setFontSize(int fontSize)
emit fontSizeChanged(m_fontSize); emit fontSizeChanged(m_fontSize);
} }
void Slide::changeSlide(int index) void Slide::changeSlide(QVariantMap item)
{ {
QVariantMap item = services.getItem(index); setType(item.value("type").toString());
if (item.backgroundType == "image") {
setImageBackground(item.background); if (item.value("backgroundType") == "image") {
setImageBackground(item.value("background").toString());
setVideoBackground(""); setVideoBackground("");
} else { } else {
setVideoBackground(item.background); setVideoBackground(item.value("background").toString());
setImageBackground(""); setImageBackground("");
} }
if (item.text.length < 1)
setText(item.text[0]); QStringList text = item.value("text").toStringList();
if (text.isEmpty())
setText("");
else {
setText(text[0]);
}
qDebug() << "MAP: " << item.value("text");
} }
void Slide::nextSlide() void Slide::nextSlide()

View file

@ -10,6 +10,7 @@ class Slide : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged) Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged)
Q_PROPERTY(QString imageBackground READ imageBackground WRITE setImageBackground NOTIFY imageBackgroundChanged) Q_PROPERTY(QString imageBackground READ imageBackground WRITE setImageBackground NOTIFY imageBackgroundChanged)
Q_PROPERTY(QString videoBackground READ videoBackground WRITE setVideoBackground NOTIFY videoBackgroundChanged) Q_PROPERTY(QString videoBackground READ videoBackground WRITE setVideoBackground NOTIFY videoBackgroundChanged)
@ -25,9 +26,10 @@ public:
explicit Slide(QObject *parent = nullptr); explicit Slide(QObject *parent = nullptr);
Slide(const QString &text, const QString &audio, const QString &imageBackground, const QString &videoBackground, Slide(const QString &text, const QString &audio, const QString &imageBackground, const QString &videoBackground,
const QString &horizontalTextAlignment, const QString &verticalTextAlignment, const QString &horizontalTextAlignment, const QString &verticalTextAlignment,
const QString &font, const int &fontSize, QObject * parent = nullptr); const QString &font, const int &fontSize, const QString &type, QObject * parent = nullptr);
QString text() const; QString text() const;
QString type() const;
QString audio() const; QString audio() const;
QString imageBackground() const; QString imageBackground() const;
QString videoBackground() const; QString videoBackground() const;
@ -37,6 +39,7 @@ public:
int fontSize() const; int fontSize() const;
Q_INVOKABLE void setText(QString text); Q_INVOKABLE void setText(QString text);
Q_INVOKABLE void setType(QString type);
Q_INVOKABLE void setAudio(QString audio); Q_INVOKABLE void setAudio(QString audio);
Q_INVOKABLE void setImageBackground(QString imageBackground); Q_INVOKABLE void setImageBackground(QString imageBackground);
Q_INVOKABLE void setVideoBackground(QString videoBackground); Q_INVOKABLE void setVideoBackground(QString videoBackground);
@ -45,11 +48,12 @@ public:
Q_INVOKABLE void setFont(QString font); Q_INVOKABLE void setFont(QString font);
Q_INVOKABLE void setFontSize(int fontSize); Q_INVOKABLE void setFontSize(int fontSize);
Q_INVOKABLE void changeSlide(int index); Q_INVOKABLE void changeSlide(QVariantMap item);
Q_INVOKABLE void nextSlide(); Q_INVOKABLE void nextSlide();
signals: signals:
Q_INVOKABLE void textChanged(QString text); Q_INVOKABLE void textChanged(QString text);
Q_INVOKABLE void typeChanged(QString type);
Q_INVOKABLE void audioChanged(QString audio); Q_INVOKABLE void audioChanged(QString audio);
Q_INVOKABLE void imageBackgroundChanged(QString imageBackground); Q_INVOKABLE void imageBackgroundChanged(QString imageBackground);
Q_INVOKABLE void videoBackgroundChanged(QString videoBackground); Q_INVOKABLE void videoBackgroundChanged(QString videoBackground);
@ -61,6 +65,7 @@ signals:
private: private:
int m_id; int m_id;
QString m_text; QString m_text;
QString m_type;
QString m_audio; QString m_audio;
QString m_imageBackground; QString m_imageBackground;
QString m_videoBackground; QString m_videoBackground;