moving more functions to slide class
This commit is contained in:
parent
dbc6b5e33a
commit
964eefb7de
4 changed files with 45 additions and 32 deletions
|
@ -94,8 +94,7 @@ int main(int argc, char *argv[])
|
|||
qDebug() << QIcon::themeName();
|
||||
|
||||
//Need to instantiate our slide
|
||||
ServiceItemModel services();
|
||||
QScopedPointer<Slide> slide(new Slide("", "", "", "", "", "", "", 0));
|
||||
QScopedPointer<Slide> slide(new Slide);
|
||||
|
||||
// apparently mpv needs this class set
|
||||
// let's register mpv as well
|
||||
|
|
|
@ -121,30 +121,17 @@ Controls.Page {
|
|||
function changeServiceItem(index) {
|
||||
const item = serviceItemModel.getItem(index);
|
||||
print("index grabbed: " + index);
|
||||
|
||||
print(item);
|
||||
|
||||
presentation.stopVideo()
|
||||
presentation.itemType = item.type;
|
||||
print("Time to start changing");
|
||||
|
||||
if (item.backgroundType === "image") {
|
||||
print("The slides backgorund is: " + SlideObject.imageBackground);
|
||||
SlideObject.setVideoBackground("");
|
||||
SlideObject.setImageBackground(item.background);
|
||||
} else {
|
||||
print("The slides backgorund is: " + SlideObject.videoBackground);
|
||||
SlideObject.setImageBackground("");
|
||||
SlideObject.setVideoBackground(item.background);
|
||||
presentation.loadVideo()
|
||||
}
|
||||
SlideObject.changeSlide(item);
|
||||
|
||||
if (item.backgroundType === "video")
|
||||
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.changeSlide();
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ Slide::Slide(QObject *parent)
|
|||
Slide::Slide(const QString &text, const QString &audio, const QString &imageBackground,
|
||||
const QString &videoBackground, const QString &horizontalTextAlignment,
|
||||
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),
|
||||
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() << m_imageBackground;
|
||||
|
@ -25,6 +25,10 @@ QString Slide::text() const {
|
|||
return m_text;
|
||||
}
|
||||
|
||||
QString Slide::type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QString Slide::audio() const {
|
||||
return m_audio;
|
||||
}
|
||||
|
@ -69,6 +73,16 @@ void Slide::setText(QString 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)
|
||||
{
|
||||
if (m_audio == audio)
|
||||
|
@ -134,18 +148,26 @@ void Slide::setFontSize(int fontSize)
|
|||
emit fontSizeChanged(m_fontSize);
|
||||
}
|
||||
|
||||
void Slide::changeSlide(int index)
|
||||
void Slide::changeSlide(QVariantMap item)
|
||||
{
|
||||
QVariantMap item = services.getItem(index);
|
||||
if (item.backgroundType == "image") {
|
||||
setImageBackground(item.background);
|
||||
setType(item.value("type").toString());
|
||||
|
||||
if (item.value("backgroundType") == "image") {
|
||||
setImageBackground(item.value("background").toString());
|
||||
setVideoBackground("");
|
||||
} else {
|
||||
setVideoBackground(item.background);
|
||||
setVideoBackground(item.value("background").toString());
|
||||
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()
|
||||
|
|
|
@ -10,6 +10,7 @@ class Slide : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
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 imageBackground READ imageBackground WRITE setImageBackground NOTIFY imageBackgroundChanged)
|
||||
Q_PROPERTY(QString videoBackground READ videoBackground WRITE setVideoBackground NOTIFY videoBackgroundChanged)
|
||||
|
@ -25,9 +26,10 @@ public:
|
|||
explicit Slide(QObject *parent = nullptr);
|
||||
Slide(const QString &text, const QString &audio, const QString &imageBackground, const QString &videoBackground,
|
||||
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 type() const;
|
||||
QString audio() const;
|
||||
QString imageBackground() const;
|
||||
QString videoBackground() const;
|
||||
|
@ -37,6 +39,7 @@ public:
|
|||
int fontSize() const;
|
||||
|
||||
Q_INVOKABLE void setText(QString text);
|
||||
Q_INVOKABLE void setType(QString type);
|
||||
Q_INVOKABLE void setAudio(QString audio);
|
||||
Q_INVOKABLE void setImageBackground(QString imageBackground);
|
||||
Q_INVOKABLE void setVideoBackground(QString videoBackground);
|
||||
|
@ -45,11 +48,12 @@ public:
|
|||
Q_INVOKABLE void setFont(QString font);
|
||||
Q_INVOKABLE void setFontSize(int fontSize);
|
||||
|
||||
Q_INVOKABLE void changeSlide(int index);
|
||||
Q_INVOKABLE void changeSlide(QVariantMap item);
|
||||
Q_INVOKABLE void nextSlide();
|
||||
|
||||
signals:
|
||||
Q_INVOKABLE void textChanged(QString text);
|
||||
Q_INVOKABLE void typeChanged(QString type);
|
||||
Q_INVOKABLE void audioChanged(QString audio);
|
||||
Q_INVOKABLE void imageBackgroundChanged(QString imageBackground);
|
||||
Q_INVOKABLE void videoBackgroundChanged(QString videoBackground);
|
||||
|
@ -61,6 +65,7 @@ signals:
|
|||
private:
|
||||
int m_id;
|
||||
QString m_text;
|
||||
QString m_type;
|
||||
QString m_audio;
|
||||
QString m_imageBackground;
|
||||
QString m_videoBackground;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue