Basic openoffice.org control, and listening for new presentation documents, still...
[kworship.git] / unipresent / kpresenter2 / UpKpr2Slide.cpp
blob9f031e61479dadf8ff5ed35f98a24af945ca845b
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 /**
21 * @file UpKpr2Slide.cpp
22 * @brief KPresenter 2 presentation slide.
23 * @author James Hogan <james@albanarts.com>
26 #include "UpKpr2Slide.h"
27 #include "UpKpr2Presentation.h"
29 #include <KLocale>
31 #include <QTemporaryFile>
32 #include <QDBusReply>
33 #include <QTextDocument>
36 * Constructors + destructor
39 /// Primary constructor.
40 UpKpr2Slide::UpKpr2Slide(UpKpr2Presentation* presentation, int index)
41 : UpSlide(presentation)
42 , m_presentation(presentation)
43 , m_index(index)
44 , m_title()
45 , m_outline()
46 , m_notesHtml()
47 , m_preview()
51 /// Destructor.
52 UpKpr2Slide::~UpKpr2Slide()
57 * Main interface
60 QString UpKpr2Slide::title()
62 if (m_title.isNull())
64 QDBusInterface* view = m_presentation->dbusView();
65 if (0 != view)
67 m_title = (QDBusReply<QString>)view->call("pageName", m_index);
70 if (m_title.isEmpty())
72 return i18n("Page %1", m_index + 1);
74 else
76 return m_title;
80 QString UpKpr2Slide::outline()
82 return QString();
85 bool UpKpr2Slide::writeNotes(QTextDocument* doc)
87 if (m_notesHtml.isNull())
89 QDBusInterface* view = m_presentation->dbusView();
90 if (0 != view)
92 m_notesHtml = (QDBusReply<QString>)view->call("pageNotes", m_index, "html");
94 else
96 return UpSlide::writeNotes(doc);
99 doc->setHtml(m_notesHtml);
100 return true;
103 QPixmap UpKpr2Slide::preview()
105 if (m_preview.isNull())
107 QDBusInterface* view = m_presentation->dbusView();
108 if (view)
110 QTemporaryFile previewFile;
111 previewFile.open();
113 QDBusMessage result = view->call(
114 "exportPageThumbnail",
115 m_index, // page
116 167, 125, // size
117 previewFile.fileName(), // filename
118 "PPM", // format
119 -1 // quality
121 if (QDBusMessage::ReplyMessage == result.type())
123 if (result.arguments().first().toBool())
125 m_preview.load(previewFile.fileName());
130 return m_preview;
133 #include "UpKpr2Slide.moc"