Commit 703ed15d authored by Albert Astals Cid's avatar Albert Astals Cid

port to dbus, at least compiles, but i'm not sure it'll work

svn path=/branches/work/kde4/playground/graphics/okular/; revision=548432
parent 48b4c272
......@@ -99,8 +99,6 @@ set(oKularpart_PART_SRCS part.cpp ${oKularui_SRCS} ${oKularagg2_SRCS} )
kde4_automoc(${oKularpart_PART_SRCS})
kde4_add_dcop_skels(oKularpart_PART_SRCS dcop.h )
kde4_add_plugin(oKularpart WITH_PREFIX ${oKularpart_PART_SRCS})
kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} oKularpart )
......
/***************************************************************************
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _KPDF_DCOP_INTERFACE_H_
#define _KPDF_DCOP_INTERFACE_H_
#include <dcopobject.h>
#include <kurl.h>
class okular_dcop : virtual public DCOPObject
{
K_DCOP
k_dcop:
virtual ASYNC goToPage( uint page ) = 0;
virtual ASYNC openDocument( KUrl doc ) = 0;
virtual uint pages() = 0;
virtual uint currentPage() = 0;
virtual KUrl currentDocument() = 0;
virtual void slotPreferences() = 0;
virtual void slotFind() = 0;
virtual void slotPrintPreview() = 0;
virtual void slotPreviousPage() = 0;
virtual void slotNextPage() = 0;
virtual void slotGotoFirst() = 0;
virtual void slotGotoLast() = 0;
};
#endif
......@@ -29,8 +29,6 @@
#include <kvbox.h>
#include <qtoolbox.h>
#include <qpushbutton.h>
#include <dcopobject.h>
#include <dcopclient.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kdirwatch.h>
......@@ -84,10 +82,12 @@ using namespace oKular;
Part::Part(QWidget *parentWidget,
QObject *parent,
const QStringList & /*args*/ )
: DCOPObject("oKular"), KParts::ReadOnlyPart(parent), m_viewportDirty( 0 ),
: KParts::ReadOnlyPart(parent), m_viewportDirty( 0 ),
m_showMenuBarAction(0), m_showFullScreenAction(0), m_actionsSearched(false),
m_searchStarted(false)
{
QDBus::sessionBus().registerObject("", this, QDBusConnection::ExportSlots);
// connect the started signal to tell the job the mimetypes we like
connect(this, SIGNAL(started(KIO::Job *)), this, SLOT(setMimeTypes(KIO::Job *)));
// load catalog for translation
......
......@@ -21,7 +21,8 @@
#include <qpointer.h>
#include "core/observer.h"
#include "core/document.h"
#include "dcop.h"
#include <dbus/qdbus.h>
class QWidget;
class QSplitter;
......@@ -58,9 +59,10 @@ class BrowserExtension;
* @author Wilco Greven <greven@kde.org>
* @version 0.2
*/
class Part : public KParts::ReadOnlyPart, public DocumentObserver, virtual public okular_dcop
class Part : public KParts::ReadOnlyPart, public DocumentObserver
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.oKular")
public:
// Default constructor
......@@ -75,11 +77,19 @@ public:
static KAboutData* createAboutData();
ASYNC goToPage(uint page);
ASYNC openDocument(KUrl doc);
uint pages();
uint currentPage();
KUrl currentDocument();
public slots: // dbus
Q_SCRIPTABLE Q_ASYNC void goToPage(uint page);
Q_SCRIPTABLE Q_ASYNC void openDocument(KUrl doc);
Q_SCRIPTABLE uint pages();
Q_SCRIPTABLE uint currentPage();
Q_SCRIPTABLE KUrl currentDocument();
Q_SCRIPTABLE void slotPreferences();
Q_SCRIPTABLE void slotFind();
Q_SCRIPTABLE void slotPrintPreview();
Q_SCRIPTABLE void slotPreviousPage();
Q_SCRIPTABLE void slotNextPage();
Q_SCRIPTABLE void slotGotoFirst();
Q_SCRIPTABLE void slotGotoLast();
signals:
void enablePrintAction(bool enable);
......@@ -97,19 +107,12 @@ protected slots:
// connected to actions
void openURLFromDocument(const KUrl &url);
void slotGoToPage();
void slotPreviousPage();
void slotNextPage();
void slotGotoFirst();
void slotGotoLast();
void slotHistoryBack();
void slotHistoryNext();
void slotFind();
void slotFindNext();
void slotSaveFileAs();
void slotGetNewStuff();
void slotPreferences();
void slotNewConfig();
void slotPrintPreview();
void slotShowMenu(const KPDFPage *page, const QPoint &point);
void slotShowProperties();
void slotShowEmbeddedFiles();
......
......@@ -34,7 +34,6 @@
#include <kmenubar.h>
#include <kparts/componentfactory.h>
#include <kio/netaccess.h>
#include <kmainwindowiface.h>
#include <krecentfilesaction.h>
#include <kservicetypetrader.h>
#include <ktoggleaction.h>
......@@ -101,10 +100,10 @@ void Shell::init()
connect( m_part, SIGNAL( enablePrintAction(bool) ), m_printAction, SLOT( setEnabled(bool)));
readSettings();
if (!KGlobal::config()->hasGroup("MainWindow"))
{
KMainWindowInterface kmwi(this);
kmwi.maximize();
showMaximized();
}
setAutoSaveSettings();
......
......@@ -30,7 +30,6 @@
#include <qapplication.h>
#include <qclipboard.h>
#include <QX11Info>
#include <dcopclient.h>
#include <kiconloader.h>
#include <kaction.h>
#include <kstdaccel.h>
......@@ -1409,13 +1408,11 @@ if (d->document->handleEvent( e ) )
else if ( choice == speakText )
{
// [2] speech selection using KTTSD
DCOPClient * client = DCOPClient::mainClient();
// Albert says is this ever necessary?
// we already attached on Part constructor
// if ( !client->isAttached() )
// client->attach();
// If KTTSD not running, start it.
if (!client->isApplicationRegistered("kttsd"))
#warning need to check the name the kttsd service gets and fix it here
if (!QDBus::sessionBus().busService()->nameHasOwner("org.kde.kttsd"))
{
QString error;
if (KToolInvocation::startServiceByDesktopName("kttsd", QStringList(), &error))
......@@ -1429,6 +1426,8 @@ if (d->document->handleEvent( e ) )
{
// serialize the text to speech (selectedText) and the
// preferred reader ("" is the default voice) ...
/*
OLD DCOP CODE
QByteArray data;
QDataStream arg( &data, IO_WriteOnly );
arg.setVersion(QDataStream::Qt_3_1);
......@@ -1443,7 +1442,11 @@ if (d->document->handleEvent( e ) )
QDataStream arg2(&data2, IO_WriteOnly);
arg2 << 0;
client->send("kttsd", "KSpeech", "startText(uint)", data2 );
}
}*/
#warning this is probably wrong, check when kttsd is dbus ported
QDBusInterfacePtr kspeech("org.kde.kttsd", "/modules/KSpeech", "org.kde.KSpeech");
kspeech->call("setText", selectedText, QString());
kspeech->call("startText", 0);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment