From 26ed416349da55f45a4b23be75bb7a646b68394f Mon Sep 17 00:00:00 2001 From: James Hogan Date: Tue, 7 Oct 2008 01:58:19 +0100 Subject: [PATCH] Added preview capabilities to kpresenter2 backend and some tweaks --- unipresent/kpresenter2/UpKpr2Presentation.cpp | 30 ++++++++++++++++++++++++--- unipresent/kpresenter2/UpKpr2Presentation.h | 10 +++++++++ unipresent/kpresenter2/UpKpr2Slide.cpp | 27 ++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/unipresent/kpresenter2/UpKpr2Presentation.cpp b/unipresent/kpresenter2/UpKpr2Presentation.cpp index 51324ff..c3b4236 100644 --- a/unipresent/kpresenter2/UpKpr2Presentation.cpp +++ b/unipresent/kpresenter2/UpKpr2Presentation.cpp @@ -91,7 +91,7 @@ QString UpKpr2Presentation::currentSlideshow() if (QDBusMessage::ReplyMessage == result.type()) { QString slideshow = result.arguments().first().toString(); - if (slideshow != "") + if (!slideshow.isEmpty()) { return slideshow; } @@ -138,12 +138,20 @@ void UpKpr2Presentation::editCustomSlideshowsDialog() int UpKpr2Presentation::numSlides() { + if (m_dbusView) + { + QDBusMessage result = m_dbusView->call("numCustomSlideShowSlides"); + if (QDBusMessage::ReplyMessage == result.type()) + { + return result.arguments().first().toInt(); + } + } return 0; } UpSlide* UpKpr2Presentation::slide(int index) { - return 0; + return new UpKpr2Slide(this, index); } /* @@ -281,12 +289,28 @@ void UpKpr2Presentation::nextStep() } /* + * Backend specific interface. + */ + +/// Get the dbus interface. +QDBusInterface& UpKpr2Presentation::dbus() +{ + return m_dbus; +} + +/// Get the dbus view interface. +QDBusInterface* UpKpr2Presentation::dbusView() +{ + return m_dbusView; +} + +/* * DBus slots */ void UpKpr2Presentation::dbusCurrentSlideshowChanged(QString slideshow) { - if (slideshow == "") + if (slideshow.isEmpty()) { slideshow = tr("All slides"); } diff --git a/unipresent/kpresenter2/UpKpr2Presentation.h b/unipresent/kpresenter2/UpKpr2Presentation.h index 239d29f..713497a 100644 --- a/unipresent/kpresenter2/UpKpr2Presentation.h +++ b/unipresent/kpresenter2/UpKpr2Presentation.h @@ -86,6 +86,16 @@ class UpKpr2Presentation : public UpPresentation virtual void previousStep(); virtual void nextStep(); + /* + * Backend specific interface. + */ + + /// Get the dbus interface. + QDBusInterface& dbus(); + + /// Get the dbus view interface. + QDBusInterface* dbusView(); + private slots: /* diff --git a/unipresent/kpresenter2/UpKpr2Slide.cpp b/unipresent/kpresenter2/UpKpr2Slide.cpp index 2126425..4839086 100644 --- a/unipresent/kpresenter2/UpKpr2Slide.cpp +++ b/unipresent/kpresenter2/UpKpr2Slide.cpp @@ -26,6 +26,8 @@ #include "UpKpr2Slide.h" #include "UpKpr2Presentation.h" +#include + /* * Constructors + destructor */ @@ -67,6 +69,31 @@ QString UpKpr2Slide::notes() QPixmap UpKpr2Slide::preview() { + if (m_preview.isNull()) + { + QDBusInterface* view = m_presentation->dbusView(); + if (view) + { + QTemporaryFile previewFile; + previewFile.open(); + + QDBusMessage result = view->call( + "exportPageThumbnail", + m_index, // page + 167, 125, // size + previewFile.fileName(), // filename + "PPM", // format + -1 // quality + ); + if (QDBusMessage::ReplyMessage == result.type()) + { + if (result.arguments().first().toBool()) + { + m_preview.load(previewFile.fileName()); + } + } + } + } return m_preview; } -- 2.11.4.GIT