1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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 ***************************************************************************/
21 * @file UpKpr2Presentation.cpp
22 * @brief KPresenter 2 presentation.
23 * @author James Hogan <james@albanarts.com>
26 #include "UpKpr2Presentation.h"
27 #include "UpKpr2Slide.h"
28 #include "UpKpr2Backend.h"
39 * Constructors + destructor
42 /// Primary constructor.
43 UpKpr2Presentation::UpKpr2Presentation(QString service
, QString path
, UpKpr2Backend
* backend
, QObject
* parent
)
44 : UpPresentation(backend
, parent
)
45 , m_dbus(service
, path
, "org.kde.koffice.document")
48 , m_customSlideshowsDialog(false)
52 m_url
= m_dbus
.call("url").arguments().first().toString();
53 if ((QDBusReply
<int>)m_dbus
.call("viewCount") > 0)
55 QString viewPath
= "/" + (QDBusReply
<QString
>)m_dbus
.call("view", 0);
56 m_dbusView
= new QDBusInterface(service
, viewPath
, "org.kde.koffice.presentation.view");
58 QDBusConnection::sessionBus().connect(service
, viewPath
, "org.kde.koffice.presentation.view", "activeCustomSlideShowChanged", this, SLOT(dbusCurrentSlideshowChanged(QString
)));
59 QDBusConnection::sessionBus().connect(service
, viewPath
, "org.kde.koffice.presentation.view", "customSlideShowsModified", this, SIGNAL(customSlideshowsModified()));
61 QDBusConnection::sessionBus().connect(service
, viewPath
, "org.kde.koffice.presentation.view", "presentationStarted", this, SLOT(dbusScreenStarted(int)));
62 QDBusConnection::sessionBus().connect(service
, viewPath
, "org.kde.koffice.presentation.view", "presentationStopped", this, SIGNAL(slideshowStopped()));
64 QDBusConnection::sessionBus().connect(service
, viewPath
, "org.kde.koffice.presentation.view", "presentationPageChanged", this, SIGNAL(slideshowSlideChanged(int, int)));
65 QDBusConnection::sessionBus().connect(service
, viewPath
, "org.kde.koffice.presentation.view", "presentationStepChanged", this, SIGNAL(slideshowStepChanged(int)));
71 UpKpr2Presentation::~UpKpr2Presentation()
80 void UpKpr2Presentation::close()
84 QUrl
UpKpr2Presentation::url() const
93 QString
UpKpr2Presentation::currentSlideshow()
97 QDBusReply
<QString
> result
= m_dbusView
->call("activeCustomSlideShow");
100 QString slideshow
= result
;
101 if (!slideshow
.isEmpty())
107 return i18n("All slides");
110 QStringList
UpKpr2Presentation::slideshows()
113 results
<< i18n("All slides");
116 QDBusReply
<QStringList
> reply
= m_dbusView
->call("customSlideShows");
125 void UpKpr2Presentation::setSlideshow(QString slideshow
)
127 if (slideshow
== i18n("All slides"))
129 slideshow
= QString();
133 m_dbusView
->call("setActiveCustomSlideShow", slideshow
);
137 int UpKpr2Presentation::numSlides()
141 QDBusReply
<int> result
= m_dbusView
->call("numCustomSlideShowSlides");
142 if (result
.isValid())
150 UpSlide
* UpKpr2Presentation::slide(int index
)
152 return new UpKpr2Slide(this, index
);
156 * Slideshow accessors
159 bool UpKpr2Presentation::isSlideshowRunning()
163 QDBusReply
<bool> result
= m_dbusView
->call("isPresentationRunning");
164 if (result
.isValid())
172 int UpKpr2Presentation::numSlidesInSlideshow()
176 QDBusReply
<int> result
= m_dbusView
->call("numPresentationPages");
177 if (result
.isValid())
179 // There's also the finish slide
180 /// @todo the finish slide is optional, ensure this is correct
187 int UpKpr2Presentation::currentSlideshowSlide()
191 QDBusReply
<int> result
= m_dbusView
->call("currentPresentationPage");
192 if (result
.isValid())
200 int UpKpr2Presentation::stepsInCurrentSlideshowSlide()
204 QDBusReply
<int> result
= m_dbusView
->call("numStepsInPresentationPage");
205 if (result
.isValid())
218 int UpKpr2Presentation::currentSlideshowStep()
222 QDBusReply
<int> result
= m_dbusView
->call("currentPresentationStep");
223 if (result
.isValid())
235 void UpKpr2Presentation::startSlideshow()
239 m_dbusView
->call("presentationStart");
243 void UpKpr2Presentation::stopSlideshow()
247 m_dbusView
->call("presentationStop");
251 void UpKpr2Presentation::goToSlide(int index
)
255 m_dbusView
->call("gotoPresentationPage", index
);
259 void UpKpr2Presentation::previousSlide()
263 m_dbusView
->call("presentationPrevSlide");
267 void UpKpr2Presentation::nextSlide()
271 m_dbusView
->call("presentationNextSlide");
275 void UpKpr2Presentation::previousStep()
279 m_dbusView
->call("presentationPrev");
283 void UpKpr2Presentation::nextStep()
287 m_dbusView
->call("presentationNext");
292 * Backend specific interface.
295 /// Get the dbus interface.
296 QDBusInterface
& UpKpr2Presentation::dbus()
301 /// Get the dbus view interface.
302 QDBusInterface
* UpKpr2Presentation::dbusView()
311 void UpKpr2Presentation::dbusCurrentSlideshowChanged(QString slideshow
)
313 if (slideshow
.isEmpty())
315 slideshow
= i18n("All slides");
317 currentSlideshowChanged(slideshow
);
320 void UpKpr2Presentation::dbusScreenStarted(int pages
)
322 /// @todo find whether this incldues the finish page or not
323 slideshowStarted(pages
-1);
330 void UpKpr2Presentation::callbackResult()
332 m_customSlideshowsDialog
= false;
335 void UpKpr2Presentation::callbackError()
337 m_customSlideshowsDialog
= false;
340 #include "UpKpr2Presentation.moc"