summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2007-07-21 14:03:31 +0100
committerBenjamin Otte <otte@gnome.org>2007-07-21 14:03:31 +0100
commit464802ff5644ea32ebf4b4c17b99c99be1ea4bc1 (patch)
treec69b6d4583fa7fd10d69be7a08dba9a5af6622c6
parent928c322a8a92100c147d4c68712e0ad2e0f50aa8 (diff)
initial commit of KDE4 codekde4
-rw-r--r--CMakeLists.txt21
-rw-r--r--flashplayer_part.cpp7
-rw-r--r--flashplayer_part.h6
-rw-r--r--flashplayerwidget.cpp76
-rw-r--r--flashplayerwidget.h6
5 files changed, 47 insertions, 69 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bef517a..05358c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,13 +1,11 @@
project( flashplayer_kpart )
-# KDE 3
-find_package(Qt3 REQUIRED)
-find_package(KDE3 REQUIRED)
-add_definitions( ${QT_DEFINITIONS} ${KDE3_DEFINITIONS} )
-
-include_directories(${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR})
-include_directories(${CMAKE_BINARY_DIR})
+# KDE 4
+find_package(KDE4 REQUIRED)
+include( KDE4Defaults )
+include( MacroLibrary )
+include_directories(${KDE4_INCLUDES})
include( UsePkgConfig )
@@ -26,8 +24,7 @@ set( flashplayer_PART_SRCS
flashplayerwidget.cpp
flashplayer_part.cpp )
-kde3_automoc(${flashplayer_PART_SRCS})
-kde3_add_kpart(flashplayerpart WITH_PREFIX ${flashplayer_PART_SRCS} )
+kde4_add_plugin(flashplayerpart WITH_PREFIX ${flashplayer_PART_SRCS} )
# add link flags for Glib, Cairo, Swfdec
set_target_properties( flashplayerpart PROPERTIES LINK_FLAGS "${GLibLinkFlags} ${CairoLinkFlags} ${SWFDecLinkFlags}" )
@@ -36,8 +33,8 @@ set_source_files_properties( ${flashplayer_PART_SRCS} PROPERTIES
COMPILE_FLAGS "${GLibCFlags} ${CairoCFlags} ${SWFDecCFlags}" )
-target_link_libraries( flashplayerpart ${KDE3_KPARTS_LIBS} swfdec-0.5 cairo )
-install(TARGETS flashplayerpart DESTINATION ${KDE3PREFIX}/lib/kde3 )
+target_link_libraries( flashplayerpart ${KDE4_KPARTS_LIBS} swfdec-0.5 cairo )
+install(TARGETS flashplayerpart DESTINATION ${PLUGIN_INSTALL_DIR} )
# install .desktop file to associate part with Flash mimetype
-install( FILES flashplayerpart.desktop DESTINATION ${KDE3PREFIX}/share/services )
+install( FILES flashplayerpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/flashplayer_part.cpp b/flashplayer_part.cpp
index f2ee16f..c3c3f9b 100644
--- a/flashplayer_part.cpp
+++ b/flashplayer_part.cpp
@@ -2,9 +2,6 @@
// Own
#include "flashplayer_part.h"
-// Qt
-#include <qurl.h>
-
// Local
#include "flashplayerwidget.h"
@@ -21,10 +18,8 @@ extern "C"
using namespace FlashPlayer;
KParts::Part* PartFactory::createPartObject( QWidget* parentWidget,
- const char* /* something */,
QObject* parent,
const char* /*classname*/,
- const char* /* something_2 */,
const QStringList& /*args*/)
{
return new Part(parentWidget,parent);
@@ -46,7 +41,7 @@ Part::Part(QWidget* parentWidget , QObject* parent)
}
bool Part::openFile()
{
- d->player->load( QUrl(url().path()) );
+ d->player->load(localFilePath());
d->player->play();
return true;
diff --git a/flashplayer_part.h b/flashplayer_part.h
index ca1f010..c3f8e71 100644
--- a/flashplayer_part.h
+++ b/flashplayer_part.h
@@ -2,8 +2,8 @@
#define FLASHPLAYER_PART_H
// KDE
-#include <kparts/factory.h>
-#include <kparts/part.h>
+#include <KParts/Factory>
+#include <KParts/Part>
class QStringList;
@@ -16,10 +16,8 @@ class PartFactory : public KParts::Factory
protected:
/** Reimplemented to create Konsole parts. */
virtual KParts::Part* createPartObject(QWidget* parentWidget = 0,
- const char* something = 0,
QObject* parent = 0,
const char* classname = "KParts::Part",
- const char* something_2 = 0,
const QStringList& args = QStringList());
};
diff --git a/flashplayerwidget.cpp b/flashplayerwidget.cpp
index 847a130..fcd9966 100644
--- a/flashplayerwidget.cpp
+++ b/flashplayerwidget.cpp
@@ -3,11 +3,11 @@
#include "flashplayerwidget.h"
// Qt
-#include "qapplication.h"
-#include "qpainter.h"
-#include "qpixmap.h"
-#include "qtimer.h"
-#include "qurl.h"
+#include <QPaintEvent>
+#include <QPainter>
+#include <QTimer>
+#include <QX11Info>
+#include <QtDebug>
// Cairo
#include <X11/Xlib.h>
@@ -24,7 +24,6 @@ public:
{
player = 0;
loader = 0;
- backingPixmap = 0;
surface = 0;
timer = 0;
mouseButton = 0;
@@ -32,9 +31,8 @@ public:
SwfdecPlayer* player;
SwfdecLoader* loader;
-
- QPixmap backingPixmap;
cairo_surface_t* surface;
+ QPixmap backingPixmap;
QTimer* timer;
@@ -50,7 +48,7 @@ FlashPlayerWidget::FlashPlayerWidget(QWidget* parent)
, d(new Private)
{
// widget attributes
- setWFlags( getWFlags() | Qt::WNoAutoErase );
+ setAttribute(Qt::WA_OpaquePaintEvent);
setMouseTracking(true);
// load swfdec
@@ -58,6 +56,8 @@ FlashPlayerWidget::FlashPlayerWidget(QWidget* parent)
{
swfdec_init();
Private::swfDecStarted = true;
+
+ qDebug() << "Started swfdec";
}
// setup player
@@ -65,7 +65,7 @@ FlashPlayerWidget::FlashPlayerWidget(QWidget* parent)
// setup timer to advance movie
d->timer = new QTimer(this);
- d->timer->changeInterval(40);
+ d->timer->setInterval(40);
connect( d->timer , SIGNAL(timeout()) , this , SLOT(advance()) );
}
FlashPlayerWidget::~FlashPlayerWidget()
@@ -78,28 +78,31 @@ void FlashPlayerWidget::resizeEvent( QResizeEvent* event )
}
void FlashPlayerWidget::prepareSurface()
{
+ // Qt backing pixmap
+ d->backingPixmap = QPixmap(width(),height());
+
// cairo surface
if ( d->surface )
cairo_surface_destroy( d->surface );
- d->backingPixmap = QPixmap(width(),height());
-
- // TODO - Find a way to get correct screen, visual rather
- // than just the default ones
- Display* display = d->backingPixmap.x11Display();
- int screen = d->backingPixmap.x11Screen();
- void* visual = d->backingPixmap.x11Visual();
-
- d->surface = cairo_xlib_surface_create( display ,
- d->backingPixmap.handle(),
- (Visual*)visual,
- width(),
- height() );
+ d->surface = cairo_xlib_surface_create( QX11Info::display() , d->backingPixmap.handle() ,
+ (Visual*)(d->backingPixmap.x11Info().visual()) ,
+ d->backingPixmap.width() ,
+ d->backingPixmap.height() );
}
void FlashPlayerWidget::paintEvent( QPaintEvent* event )
{
+ // create cairo painter
+ cairo_t* painter = cairo_create(d->surface);
+
+ // render movie
+ swfdec_player_render( d->player , painter , 0 , 0 , width() , height() );
+
+ // cleanup
+ cairo_show_page(painter);
+ cairo_destroy(painter);
- // copy to screen
+ // copy pixmap to screen
QPainter qtPainter(this);
qtPainter.drawPixmap(0,0,d->backingPixmap);
}
@@ -128,35 +131,22 @@ void FlashPlayerWidget::handleMouseEvent( QMouseEvent* event )
void FlashPlayerWidget::advance()
{
swfdec_player_advance( d->player , swfdec_player_get_next_event(d->player) );
-
- render();
- update();
-}
-void FlashPlayerWidget::render()
-{
- // create cairo painter
- cairo_t* painter = cairo_create(d->surface);
-
- // render movie
- swfdec_player_render( d->player , painter , 0 , 0 , width() , height() );
-
- // cleanup
- cairo_show_page(painter);
- cairo_destroy(painter);
+ update();
}
+
QSize FlashPlayerWidget::movieSize() const
{
int width;
int height;
- swfdec_player_get_image_size( d->player , &width , &height );
-
+ swfdec_player_get_image_size(d->player,&width,&height);
return QSize(width,height);
}
+
void FlashPlayerWidget::play()
{
if ( !d->timer->isActive() )
- d->timer->start(40,FALSE);
+ d->timer->start();
}
void FlashPlayerWidget::pause()
{
@@ -164,7 +154,7 @@ void FlashPlayerWidget::pause()
}
void FlashPlayerWidget::load(const QUrl& url)
{
- d->loader = swfdec_loader_new_from_file(url.path().utf8().data());
+ d->loader = swfdec_loader_new_from_file(url.toLocalFile().toUtf8().constData());
swfdec_player_set_loader(d->player,d->loader);
}
diff --git a/flashplayerwidget.h b/flashplayerwidget.h
index 99a2e1b..25c4dbd 100644
--- a/flashplayerwidget.h
+++ b/flashplayerwidget.h
@@ -3,9 +3,8 @@
#define FLASHPLAYERWIDGET_H
// Qt
-#include <qwidget.h>
-
-class QUrl;
+#include <QWidget>
+#include <QUrl>
class FlashPlayerWidget : public QWidget
{
@@ -35,7 +34,6 @@ Q_OBJECT
private:
void handleMouseEvent( QMouseEvent* event );
void prepareSurface();
- void render();
private:
class Private;