creating a slideIndex on SlideObject and referencing as active slide
This commit is contained in:
parent
84f89fb201
commit
38885a5149
3 changed files with 34 additions and 3 deletions
|
@ -20,7 +20,7 @@ Slide::Slide(const QString &text, const QString &audio, const QString &imageBack
|
|||
m_videoBackground(videoBackground),m_verticalTextAlignment(verticalTextAlignment),
|
||||
m_horizontalTextAlignment(horizontalTextAlignment),m_font(font),
|
||||
m_fontSize(fontSize),m_imageCount(imageCount),m_pdfIndex(pdfIndex),
|
||||
m_isPlaying(isPlaying),m_type(type)
|
||||
m_isPlaying(isPlaying),m_type(type),m_slideIndex(0)
|
||||
{
|
||||
qDebug() << "Initializing slide with defaults";
|
||||
}
|
||||
|
@ -81,6 +81,11 @@ int Slide::pdfIndex() const
|
|||
return m_pdfIndex;
|
||||
}
|
||||
|
||||
int Slide::slideIndex() const
|
||||
{
|
||||
return m_slideIndex;
|
||||
}
|
||||
|
||||
bool Slide::isPlaying() const
|
||||
{
|
||||
return m_isPlaying;
|
||||
|
@ -202,6 +207,16 @@ void Slide::setPdfIndex(int pdfIndex)
|
|||
emit pdfIndexChanged(m_pdfIndex);
|
||||
}
|
||||
|
||||
void Slide::setSlideIndex(int slideIndex)
|
||||
{
|
||||
if (m_slideIndex == slideIndex)
|
||||
return;
|
||||
|
||||
qDebug() << "####changing slideIndex to: " << slideIndex;
|
||||
m_slideIndex = slideIndex;
|
||||
emit slideIndexChanged(m_slideIndex);
|
||||
}
|
||||
|
||||
void Slide::changeSlide(QVariantMap item)
|
||||
{
|
||||
setServiceItem(item);
|
||||
|
@ -329,7 +344,7 @@ bool Slide::changeSlideIndex(int index)
|
|||
qDebug() << "Starting to change slide index.";
|
||||
qDebug() << "Slide Index: " << m_slideIndex << " Slide Size: " << m_slideSize;
|
||||
QStringList text = m_serviceItem.value("text").toStringList();
|
||||
if (index > m_slideSize || index < 0) {
|
||||
if (index > m_slideSize - 1 || index < 0) {
|
||||
qDebug() << "index is invalid: " << index;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ class Slide : public QObject
|
|||
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
|
||||
Q_PROPERTY(int imageCount READ imageCount WRITE setImageCount NOTIFY imageCountChanged)
|
||||
Q_PROPERTY(int pdfIndex READ pdfIndex WRITE setPdfIndex NOTIFY pdfIndexChanged)
|
||||
Q_PROPERTY(int slideIndex READ slideIndex WRITE setSlideIndex NOTIFY slideIndexChanged)
|
||||
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
|
||||
// QML_ELEMENT
|
||||
|
||||
|
@ -49,6 +50,7 @@ public:
|
|||
int fontSize() const;
|
||||
int imageCount() const;
|
||||
int pdfIndex() const;
|
||||
int slideIndex() const;
|
||||
bool isPlaying() const;
|
||||
|
||||
Q_INVOKABLE void setText(QString text);
|
||||
|
@ -63,6 +65,7 @@ public:
|
|||
Q_INVOKABLE void setFontSize(int fontSize);
|
||||
Q_INVOKABLE void setImageCount(int imageCount);
|
||||
Q_INVOKABLE void setPdfIndex(int pdfIndex);
|
||||
Q_INVOKABLE void setSlideIndex(int slideIndex);
|
||||
|
||||
Q_INVOKABLE void changeSlide(QVariantMap item);
|
||||
Q_INVOKABLE void play();
|
||||
|
@ -85,6 +88,7 @@ signals:
|
|||
Q_INVOKABLE void fontSizeChanged(int fontSize);
|
||||
Q_INVOKABLE void imageCountChanged(int imageCount);
|
||||
Q_INVOKABLE void pdfIndexChanged(int pdfIndex);
|
||||
Q_INVOKABLE void slideIndexChanged(int slideIndex);
|
||||
Q_INVOKABLE void isPlayingChanged(bool isPlaying);
|
||||
|
||||
private:
|
||||
|
|
|
@ -10,7 +10,7 @@ Item {
|
|||
// Lets set the outerModelData so we can access that data here.
|
||||
property var outerModelData: model;
|
||||
|
||||
implicitHeight: Kirigami.Units.gridUnit * 6.25
|
||||
implicitHeight: Kirigami.Units.gridUnit * 6.5
|
||||
implicitWidth: {
|
||||
let slides = outerModelData.slideNumber === 0 ? 1 : outerModelData.slideNumber
|
||||
return Kirigami.Units.gridUnit * 10 * slides + Kirigami.Units.smallSpacing * 2;
|
||||
|
@ -72,6 +72,17 @@ Item {
|
|||
onClicked: changeSlideAndIndex(outerModelData, index)
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: activeHighlightBar
|
||||
width: previewSlideItem.width
|
||||
height: Kirigami.Units.gridUnit / 4
|
||||
anchors.top: previewSlideItem.bottom
|
||||
anchors.left: previewSlideItem.left
|
||||
anchors.topMargin: Kirigami.Units.smallSpacing
|
||||
color: Kirigami.Theme.negativeTextColor
|
||||
visible: outerModelData.active && SlideObject.slideIndex == index - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,5 +124,6 @@ Item {
|
|||
if (index === 0)
|
||||
return;
|
||||
SlideObject.changeSlideIndex(index);
|
||||
console.log("New slide index is: " + SlideObject.slideIndex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue